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
azeemnazim
Helper II
Helper II

Calendar Table

Hi,  I want to know what is the best way to create a calendar table and why a calendar table is that necessary to create. How to create one in query editor?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@azeemnazim - Calendar tables are just a common dimension in many data models and Power BI wants you to use a star schema data model. You need a calendar table for many time intelligence functions to operate.

 

But, if you don't want one, there are other ways. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@azeemnazim 

Try using the following code for creating a calendar which includes the "FullDate4Sort" column to sort calendar in ascending dates. Feel free to add whatever columns you need with the Format and Date functions.

 

CALENDAR = ADDCOLUMNS(CALENDAR(DATE(2018,1,1),DATE(2030,12,31)),"FullDate4Sort",FORMAT([Date],"YYYY/MM/DD"),"DateAsInteger",FORMAT([Date],"YYYYMMDD"),"Year",YEAR([Date]),"MonthNumber",FORMAT([Date],"MM"),"YearMonthNumber",FORMAT([Date],"YYYY/MM"),"MonthNameShort",FORMAT([Date],"mmm"), "MonthNameLong",FORMAT([Date],"mmmm"), "DayOfWeekNumber",WEEKDAY([Date],1), "DayOfWeek",FORMAT([Date],"dddd"), "DayOfWeekShort",FORMAT([Date],"ddd"),"Quarter","Q"& FORMAT([Date],"Q"), "YearQuarter",FORMAT([Date],"YYYY") & "/Q" & FORMAT([Date],"Q"))
Greg_Deckler
Community Champion
Community Champion

@azeemnazim - Calendar tables are just a common dimension in many data models and Power BI wants you to use a star schema data model. You need a calendar table for many time intelligence functions to operate.

 

But, if you don't want one, there are other ways. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Ajinkya369
Resolver III
Resolver III

Hey @azeemnazim ,

 

Creating a calender table is very easy using this m query:

List.Dates(start as date, count as number, step as duration)
List.Dates(#date(2011, 12, 31), 5, #duration(1, 0, 0, 0))
12/31/2011 12:00:00 AM
1/1/2012 12:00:00 AM
1/2/2012 12:00:00 AM
1/3/2012 12:00:00 AM
1/4/2012 12:00:00 AM

 

Why calender tables is required?

  • It allows you to aggregate data by non-standard columns (think your company’s financial year, or your timesheet weeks, or the Mayan calendar!).
  • It gives you access to all of the wonderful time-intelligence functions in DAX, with names like TOTALYTD and CLOSINGBALANCE. Without a calendar table these won’t work.

 

If your problem is solved then accept this reply as solution.

 

Thank you

TomMartens
Super User
Super User

Hey,

 

this article provides a lot of examples on how to use a calendar table:

https://www.daxpatterns.com/time-patterns/

 

This article explains why one should not use a "one-table" solution and strive for a star schema data model, where a calendar table is just one of the dimension tables:

https://www.sqlbi.com/articles/understanding-dax-auto-exist/

 

Here is an example creating a calendar table using power query:

https://www.ehansalytics.com/blog/2019/3/17/create-a-dynamic-date-table-in-power-query#:~:text=%20Th...

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.