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
campelliann
Post Patron
Post Patron

Dax switching days and months

Hi,


So this is what happened to me yesterday. I was trying to use the function Format(date, "yyyy-mm-dd"), and then dax was placing me the day in the middle (instead of the month).

 

For instance the date field was like 11-02-2021 11:30:00, and then I would get, 2021-11-02 after the format. The regional settings are set in my country..


Any explanation for this?

 

Thank you!

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @campelliann 

 

Based on your description, I assume that the date format in your country is dd-mm-yyyy. You may go to 'Query Editor' and follow the steps.

 

This locale setting is important for interpreting text values into a specific data type. For example, imagine that you have your locale set as English (United States), but a column in one of your CSV files has dates formatted in the United Kingdom format of day/month/year.

g1.png

When you try setting the data type of the Date column to be Date, you get error values.

g2.png

 

These errors occur because the locale being used is trying to interpret the date in the English (United States) format, which is month/day/year. Because there's no month 22 in the calendar, it causes an error.

 

Instead of trying to just select the Date data type, you can right-click the column heading, select Change type, and then select Using locale.

g3.png

 

In the Change column type with locale dialog box, you select the data type that you want to set, but you also select which locale to use, which in this case needs to be English (United Kingdom).

g4.png

 

Then you may use dax function Format(date, "yyyy-mm-dd") to format the date column. For further information, please refer to the document .

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @campelliann 

 

Based on your description, I assume that the date format in your country is dd-mm-yyyy. You may go to 'Query Editor' and follow the steps.

 

This locale setting is important for interpreting text values into a specific data type. For example, imagine that you have your locale set as English (United States), but a column in one of your CSV files has dates formatted in the United Kingdom format of day/month/year.

g1.png

When you try setting the data type of the Date column to be Date, you get error values.

g2.png

 

These errors occur because the locale being used is trying to interpret the date in the English (United States) format, which is month/day/year. Because there's no month 22 in the calendar, it causes an error.

 

Instead of trying to just select the Date data type, you can right-click the column heading, select Change type, and then select Using locale.

g3.png

 

In the Change column type with locale dialog box, you select the data type that you want to set, but you also select which locale to use, which in this case needs to be English (United Kingdom).

g4.png

 

Then you may use dax function Format(date, "yyyy-mm-dd") to format the date column. For further information, please refer to the document .

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jaideepnema
Solution Sage
Solution Sage

Hi @campelliann  did you checked the regional settings in Power Bi Desktop ?

jaideepnema_1-1613039147116.png

If this answers your question please accept this as a solution !!

Hi, yes! The regional settings are in my country. It was very strange...

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.