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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jay2077
Helper III
Helper III

Error when creating date table

I clicked on create new table and inserted the following 

 

Date =
ADDCOLUMNS (
CALENDARAUTO(),
"Year", YEAR ( [Date] ),
"Month", FORMAT ( [Date], "mmmm" ),
"Month Number", MONTH ([Date] )
)
 
However I get the following error 
CALENDAR AUTO function can not find a base column of DATETime type in the model
 
Can anyone help with this please ?

 

 

1 ACCEPTED SOLUTION
NickolajJessen
Solution Sage
Solution Sage

Hi,

You are getting an error because this is the only table in your model so far, correct?
Import some other data containing dates and see if this works.

Reference:
https://community.powerbi.com/t5/Desktop/CALENDARAUTO-Function-not-working-properly/td-p/1297281

EDIT:
Further reading
https://endjin.com/blog/2018/06/using-calendar-vs-calendarauto-to-generate-date-table-for-year-on-ye...

The 'Previous Year Sales' will, of course, be blank – because there are no data entries for the previous year. However, care needs to be taken for the final date entries in your date table. This is where it becomes important to understand the possible differences between generating a date table using the CALENDAR function and CALENDARAUTO function.

The CALENDAR function generates a date table, outputting every day between two dates you specify as parameters (inclusive). Of course, these parameters can be hard-coded, or a function that outputs a date based on your chosen date column can be used (which is probably more preferable for dynamic data models).

For example, the FIRSTDATE and LASTDATE functions can be used in the arguments to extract the earliest and latest dates that appear in whatever date column you wish to use to generate your date table.

CALENDARAUTO works slightly differently. CALENDARAUTO will output a date table with every day from the first day of the fiscal year based on the earliest date in your chosen date column, all the way up to the last day of the fiscal year of the latest date in your chosen date column. It takes one optional parameter ([fiscal_year_end_month]) whereby you can enter an integer between 1 and 12 to choose as the end of your fiscal year. The default is 12 (31st December).

 

View solution in original post

2 REPLIES 2
Jay2077
Helper III
Helper III

Thanks 

NickolajJessen
Solution Sage
Solution Sage

Hi,

You are getting an error because this is the only table in your model so far, correct?
Import some other data containing dates and see if this works.

Reference:
https://community.powerbi.com/t5/Desktop/CALENDARAUTO-Function-not-working-properly/td-p/1297281

EDIT:
Further reading
https://endjin.com/blog/2018/06/using-calendar-vs-calendarauto-to-generate-date-table-for-year-on-ye...

The 'Previous Year Sales' will, of course, be blank – because there are no data entries for the previous year. However, care needs to be taken for the final date entries in your date table. This is where it becomes important to understand the possible differences between generating a date table using the CALENDAR function and CALENDARAUTO function.

The CALENDAR function generates a date table, outputting every day between two dates you specify as parameters (inclusive). Of course, these parameters can be hard-coded, or a function that outputs a date based on your chosen date column can be used (which is probably more preferable for dynamic data models).

For example, the FIRSTDATE and LASTDATE functions can be used in the arguments to extract the earliest and latest dates that appear in whatever date column you wish to use to generate your date table.

CALENDARAUTO works slightly differently. CALENDARAUTO will output a date table with every day from the first day of the fiscal year based on the earliest date in your chosen date column, all the way up to the last day of the fiscal year of the latest date in your chosen date column. It takes one optional parameter ([fiscal_year_end_month]) whereby you can enter an integer between 1 and 12 to choose as the end of your fiscal year. The default is 12 (31st December).

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.