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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
HCK
Frequent Visitor

Is there a way how to calculate and visualize data for missing dates using DAX

Hello,

as a relativelly new to DAX I am in front of for me relativelly big data which I assume would be better to handle on DAX lever rather than Power Query - matching qty for materials (8000+) for each day (365+) and that based on random dated input.
I have a Data table and a Calendar table (Day by Day) linked together with the key day.
Data(Day)*:1Calendar(Day)
I would like to transform the data from:

 

Data table:

DayMaterialQty
01.09.2022A10
01.09.2022B100
01.09.2022C1000
08.09.2022A20
08.09.2022B200
08.09.2022D20000
15.09.2022A30
15.09.2022B3000
15.09.2022C3000
15.09.2022D30000

 

To:

Intended result (In Matrix table) 

Day/QtyABCD
01.09.20221010010000
02.09.20221010010000
03.09.20221010010000
04.09.20221010010000
05.09.20221010010000
06.09.20221010010000
07.09.20221010010000
08.09.202220200100020000
09.09.202220200100020000
10.09.202220200100020000
11.09.202220200100020000
12.09.202220200100020000
13.09.202220200100020000
14.09.202220200100020000
15.09.2022303003000300000
16.09.2022303003000300000

 

The purpose is that the original data for saving purposes shows only data with change and I would like to reconstruct every day status.
I can imagine doing that on Power Query level however I assume that will be too big and don't think it will be the right approach.

 

I tried to do some measures to do the filling but it all seem to only reflect some dates and not all from the Calendar.

I will appreciate a lot an advice leading to the proper solution. 
Thank you very much for your help  in advance.

HCK

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@HCK , First create a new column

 

End Date = coalesce(Minx(filter(Table, [Material] = earlier([Material]) && [Date] > earlier([Date])),  [Date]), [Date]+1)

 

then use table of measure way in dax and use a matrix visual


https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

Table

https://amitchandak.medium.com/dax-get-all-dates-between-the-start-and-end-date-8f3dac4ff90b

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

@amitchandak Thank you very much. You showed me the way.
I needed to adjust the new column a bit so that it works exactly as intended to:

EndDate = coalesce(Minx(filter(Data, [Material] = earlier([Material]) && [StartDate] > earlier([StartDate])),[StartDate]-1),[StartDate]+1)

I adjusted as well the following measure differently (simplified): 
Val by day of Month = CALCULATE (SUMX(Filter(CROSSJOIN('Data','Date'),'Date'[Date] >= 'Data'[StartDate] && 'Date'[Date]<= 'Data'[EndDate]),Data[Qty]))
It leads to wanted results!
Thank you very much again!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@HCK , First create a new column

 

End Date = coalesce(Minx(filter(Table, [Material] = earlier([Material]) && [Date] > earlier([Date])),  [Date]), [Date]+1)

 

then use table of measure way in dax and use a matrix visual


https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

Table

https://amitchandak.medium.com/dax-get-all-dates-between-the-start-and-end-date-8f3dac4ff90b

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thank you very much. You showed me the way.
I needed to adjust the new column a bit so that it works exactly as intended to:

EndDate = coalesce(Minx(filter(Data, [Material] = earlier([Material]) && [StartDate] > earlier([StartDate])),[StartDate]-1),[StartDate]+1)

I adjusted as well the following measure differently (simplified): 
Val by day of Month = CALCULATE (SUMX(Filter(CROSSJOIN('Data','Date'),'Date'[Date] >= 'Data'[StartDate] && 'Date'[Date]<= 'Data'[EndDate]),Data[Qty]))
It leads to wanted results!
Thank you very much again!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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