Why does my DATEADD measure return blank for some months but not others DAX Help
Measure is Sales LY = CALCULATE([Sales], DATEADD('Date'[Date], -12, MONTH)). For most months it lines up with last year fine, but four or five months come back completely blank even though there are definitely sales rows in those months a year earlier. The date table is a query off my fact table's order dates, and I marked it as a date table. Same behaviour in a card visual, so it is not the matrix.
@idempotent_ian · 3mo ago · 3 replies
Your date table is built from distinct order dates, so it has holes in it — every day you took no orders is simply missing. Time intelligence functions require a contiguous calendar, and when DATEADD shifts into a range where some days do not exist as rows it quietly returns blank instead of erroring.
Rebuild it as its own table:
Date = CALENDAR(DATE(2021,1,1), DATE(2027,12,31)), add your year and month columns off that, relate it to the fact table, and re-mark it as the date table. Then delete the old one so nothing sneaks back in through an old relationship.Reply
Report
@csv_apologist · 3mo ago
That was it. Eleven missing days across the year, all Sundays and two public holidays. Rebuilt with CALENDAR and every month populates now. I had no idea it failed silently rather than complaining.
Reply
Report
@pinned_versions · 3mo ago
Worth adding: the calendar should cover whole years, 1 Jan to 31 Dec, not just min to max of your data. Year-to-date measures get strange at the edges otherwise.
Reply
Report