HeadlinesBriefing favicon HeadlinesBriefing.com

DAX Calendar-Based Time Intelligence Custom Logic

Towards Data Science •
×

A recent Towards Data Science article examines how calendar-based Time Intelligence in DAX impacts custom logic for calculations like running averages. The author compares classic Gregorian calendar approaches with a custom financial calendar, testing performance and code complexity. This matters because Power BI developers often need to adapt calculations for non-standard fiscal periods.

Using standard calendars, the `DATESINPERIOD()` function works seamlessly, delivering results in 150 milliseconds. However, a custom calendar without a usable date column requires more complex DAX. The initial custom approach, which calculates date ranges manually, performed poorly, taking nearly half a second to execute.

Optimization became the focus. The author improved performance by leveraging a known constant—31 days per month—to fetch the last 93 days using `TOPN()`, cutting execution time to 118 ms. Adding a `RowRank` column for direct index filtering further refined the measure, though the gains were marginal and required more data overhead.