Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ralf123
Frequent Visitor

Combine 2 tables and add missing months according to start and end date

Hello,

I would like to combine 2 tables. One with count values and the other one with start and end dates (see tables below). Now I want the result table to have the missing rows (according to start and end date) added with Count cells filled with 0 (see result table below). I already tried with Crossjoin, but then I get all the months as result and not only the ones according to the start and end date.

 

Anyone an idea how to do this?

 

Thanks

 

 

Count table

SerialDateNameCount 
xApril 20195 
xMay 20194 
xJune 20193 
yApril 20192 
yMay 20191 
yJune 20197 
zMay 20192 
zJuly 20197 
zAugust 20199 
    

 

Start/end date table

SerialStartDateEndDate 
xApril 2019June 2019 
yApril 2019July 2019 
zMay 2019August 2019 
    

 

Result table

SerialDateNameCount 
xApril 20195 
xMay 20194 
xJune 20193 
yApril 20192 
yMay 20191 
yJune 20197 
yJuly 20190 
zMay 20192 
zJune 20190 
zJuly 20197 
zAugust 20199 
    

 

1 ACCEPTED SOLUTION

@Nathaniel_C  The problem with this solution is that missing month in between the start and end dates will not be added.

 

I added some steps to the startEnd table to get all the months and now I have the right result. I followed this link to add the missing months

 

https://medium.com/dm-p/generating-rows-by-month-for-date-ranges-in-power-query-9baf62ed8e99

 

Thanks for your help!

 

afbeelding.png

View solution in original post

4 REPLIES 4
Nathaniel_C
Super User
Super User

Hi @Ralf123 ,

In your final table you have z June. Where does that come from?


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I want that to be added, just like for the y July. If you look in the start/end date table you see for y April - July and for z May - August and I want for the months that don't exist in the Count table that they are added with value 0 for Count.

Hi @Ralf123 ,

You have no z for  june that I can see. The steps are in pivot query.  Here is my pbix. PBIX

 

Serial2.PNG

Serial.PNG

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Nathaniel_C  The problem with this solution is that missing month in between the start and end dates will not be added.

 

I added some steps to the startEnd table to get all the months and now I have the right result. I followed this link to add the missing months

 

https://medium.com/dm-p/generating-rows-by-month-for-date-ranges-in-power-query-9baf62ed8e99

 

Thanks for your help!

 

afbeelding.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.