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...)
- dax6 years ago
Community Support
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.
- mahoneypat6 years ago
Microsoft Employee
Your Date table should have all the dates (and months) from the min to max date of your other table. Are you making your visuals with the Date (or month) from your Date table? If you have a measure that calculate YTD, you should get a value for each Date or Month. Have you made a table (or chart) with the Date or Month column from the Date table, and a measure like TOTALYTD(Sum(Table[Sales]), 'Date'[Date])?
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat