Forum Discussion
Get Previous Running Total for Missing Month
- 6 years ago
Hi Anonymous ,
You could create a calendat table (2019/1/~2022/12/21)
calendar = CALENDAR(date(2019,1,1), date(2022,12,31))then create relationship between calendar and fact table, and use measure and calendar in table like below,
Measure = var maxd=CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table','Table'[Item])) return CALCULATE(SUM('Table'[ Qty]), FILTER(ALLSELECTED('calendar'), 'calendar'[Date]<=MIN('calendar'[Date]) && MIN('calendar'[Date])<=maxd))It will show all months in each year, and end with the max month in fact table. You could refer to my sample for details.
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks VijayP
I checked your file but one thing that I wonder is how could you make every month in "table".
Because in my case, there is no row for missing value, even month value.
The hard thing is insert missing month row if it is missed.
For example my table looks below, I should create April.
(Sorry for Date language...)
Hi Anonymous ,
You could create a calendat table (2019/1/~2022/12/21)
calendar = CALENDAR(date(2019,1,1), date(2022,12,31))
then create relationship between calendar and fact table, and use measure and calendar in table like below,
Measure = var maxd=CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table','Table'[Item])) return CALCULATE(SUM('Table'[ Qty]), FILTER(ALLSELECTED('calendar'), 'calendar'[Date]<=MIN('calendar'[Date]) && MIN('calendar'[Date])<=maxd))
It will show all months in each year, and end with the max month in fact table. You could refer to my sample for details.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.