Forum Discussion
DAX function
What is the difference between calendar and calendar Auto. Please explain with example.
Hi Rsing
The CALENDAR and CALENDARAUTO functions in DAX are both used to generate date tables. However, there are some key differences between the two functions.
CALENDAR
The CALENDAR function takes two arguments: a start date and an end date. It returns a table with a single column named Date that contains all of the dates between the start date and the end date, inclusive.
CALENDAR(StartDate, EndDate)
For example, the following code will create a date table that contains all of the dates between January 1, 2020 and December 31, 2020:Calendar(Date(2020,1,1), Date(2020,12,31))
CALENDARAUTOThe CALENDARAUTO function does not take any arguments. It returns a table with a single column named Date that contains all of the dates in the current model. The date range is calculated automatically based on the data in the model.
CALENDARAUTO()
For example, if the current model contains a table of sales with a Date column, the CALENDARAUTO function will return a table that contains all of the dates in the Date column.Key Differences
The main difference between the CALENDAR and CALENDARAUTO functions is that the CALENDAR function allows you to specify a custom date range, while the CALENDARAUTO function automatically calculates the date range based on the data in the model.
Here is a table that summarizes the key differences between the two functions:
Also, take a look at the linked video :
https://www.youtube.com/watch?v=b23bk6TcXak
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
5 Replies
- Ritaf1983Super User
Hi Rsing
The CALENDAR and CALENDARAUTO functions in DAX are both used to generate date tables. However, there are some key differences between the two functions.
CALENDAR
The CALENDAR function takes two arguments: a start date and an end date. It returns a table with a single column named Date that contains all of the dates between the start date and the end date, inclusive.
CALENDAR(StartDate, EndDate)
For example, the following code will create a date table that contains all of the dates between January 1, 2020 and December 31, 2020:Calendar(Date(2020,1,1), Date(2020,12,31))
CALENDARAUTOThe CALENDARAUTO function does not take any arguments. It returns a table with a single column named Date that contains all of the dates in the current model. The date range is calculated automatically based on the data in the model.
CALENDARAUTO()
For example, if the current model contains a table of sales with a Date column, the CALENDARAUTO function will return a table that contains all of the dates in the Date column.Key Differences
The main difference between the CALENDAR and CALENDARAUTO functions is that the CALENDAR function allows you to specify a custom date range, while the CALENDARAUTO function automatically calculates the date range based on the data in the model.
Here is a table that summarizes the key differences between the two functions:
Also, take a look at the linked video :
https://www.youtube.com/watch?v=b23bk6TcXak
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
- Wilson_Memorable Member
Rsing,
Check this link out: https://www.sqlbi.com/tv/calendar-calendarauto-dax-guide/
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.
- Uzi2019Community Champion
Hi Rsing
Refer below video for better undertanding with proper example
https://www.youtube.com/watch?v=pIIk42R4ex4https://www.youtube.com/watch?v=wyl7Lvj2EJ8
I hope I answered your questioned!