Forum Discussion
DAX year cummulative doesn't work with blank dates
- 1 year ago
Hi olijo
As a best practice, use a separate dates table with a complete rows of dates (no missing dates in between), relate it to your fact and apply the calculation on date column from the dates table and not on from fact. Please see attached sample pbix.
- 1 year ago
In SSAS Tabular, are you using a separate dates table? Those rows of dates must exist (whether with a value or not) for DATESYTD or any other time intelligence calculations to have a value for those otherwise they will just be skipped.
Hi olijo -The issue here is that when there are missing dates (e.g., no data for June and December 2023), the DATESYTD function skips these months in the cumulative sum, resulting in gaps in your Year-To-Date (YTD) calculation.
use below calculation:
Cumulative YTD =
VAR CurrentDate = MAX('Data'[Date])
VAR CurrentYear = YEAR(CurrentDate)
RETURN
CALCULATE(
SUM('Data'[IZNOS7n]),
FILTER(
ALL('Data'),
YEAR('Data'[Date]) = CurrentYear &&
'Data'[Date] <= CurrentDate
)
)
Hope it works.