Forum Discussion
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?
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-TITHW/m-p/434008
5 Replies
- amitchandakSuper User
azeemnazim , refer these
calendar
https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columns -- power query/ M way
https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-3-public-holidays
https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-2-fiscal-columns
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.andredevelopment.com/en-US/community/blogs/powerbi/working-days-holidays-calendar/Any month calendar using dax
- TomMartensSuper 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:
Regards,
Tom
- Ajinkya369Resolver 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
- Greg_DecklerCommunity 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-TITHW/m-p/434008 - AnonymousNot applicable
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"))