Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jaryszek
Memorable Member
Memorable Member

Better to use DAX calendar table or power bi and M and why?

Hello,

 

I have this kind of code to generate dates:

DateDimension = 
ADDCOLUMNS(
    CALENDAR(DATE(2023, 2, 1), DATE(2025, 2, 1)),
    "DateKey", FORMAT([Date], "YYYYMMDD"),
    "Year", YEAR([Date]),
    "Quarter", "Q" & QUARTER([Date]),
    "QuarterNo", QUARTER([Date]),
    "Month", FORMAT([Date], "mmmm"),
    "MonthNo", MONTH([Date]),
    "MonthShort", FORMAT([Date], "mmm"),
    "WeekNo", WEEKNUM([Date]),
    "WeekDay", FORMAT([Date], "dddd"),
    "WeekDayNo", WEEKDAY([Date], 2),
    "DayOfYear", DATEDIFF(DATE(YEAR([Date]), 1, 1), [Date], DAY) + 1,
    "IsWeekend", IF(WEEKDAY([Date], 2) > 5, TRUE, FALSE),
    "IsHoliday", FALSE, // You can customize this based on your holiday calendar
    "YearMonth", FORMAT([Date], "yyyy-mm"),
    "YearQuarter", FORMAT([Date], "yyyy") & "-Q" & QUARTER([Date]),
    "FiscalYear", "FY" & IF(MONTH([Date]) > 6, YEAR([Date]) + 1, YEAR([Date])),
    "FiscalQuarter", "FQ" & IF(MONTH([Date]) > 6, QUARTER([Date]) - 2, QUARTER([Date]) + 2)
)

 

This is dax. 

I heard from my boss because he read in some article that this is better approach than writing this in power query M code - it is regarding performance and size. 

 

It is true? And why if it yes? 

 

If i will need to read speofic ranges of dates based on specific customer (like read start date, end date) dax will be better or just import them using power query? 

 

Need expertise here please,

 

Best wishes,
Jacek

1 ACCEPTED SOLUTION
Deku
Super User
Super User

Any DAX calculated table and columns are generated at the very end of a refresh. This data will still be compressed.

 

For calculated tables, the compression should be the same regardless of if the data is from DAX or powerquery.

 

In the case of calculated columns, there can be a difference. When loading data, vertipak tries to find a sort order to increase run length encoding and maximize compression. The mean you get smaller tables in memory and faster query execution. Calculated columns are calculated after this order has been determining, meaning it may have sub optimal compression.


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

2 REPLIES 2
jaryszek
Memorable Member
Memorable Member

Thanks, so calculated tables can be a good solution not having affect on general performance. 
So it is matter of implementation.

Best,
Jacek

Deku
Super User
Super User

Any DAX calculated table and columns are generated at the very end of a refresh. This data will still be compressed.

 

For calculated tables, the compression should be the same regardless of if the data is from DAX or powerquery.

 

In the case of calculated columns, there can be a difference. When loading data, vertipak tries to find a sort order to increase run length encoding and maximize compression. The mean you get smaller tables in memory and faster query execution. Calculated columns are calculated after this order has been determining, meaning it may have sub optimal compression.


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.