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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.