cancel
Showing results for 
Search instead for 
Did you mean: 
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
Super User
Super User

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
Super User
Super User

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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.