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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
alvin199
Helper III
Helper III

Convert date into fix format

I have a date column like below:

alvin199_0-1643948059483.png

 

The format is mix up. For example, the correct format should be DD.MM.YYYY. Row 1-3 are correct but 4th row is showing differnet format MM.DD.YYYY. 

 

How can I convert the the 4th row to DD.MM.YYYY?


1 ACCEPTED SOLUTION

Thanks for your explanation. The IF Then statement is how the year, month and day sequence based on DATE formula and the output display is based on our compute setting. 

 

As you have raised caution regarding the display result may be have conflict. For example, 02/12/2022 (text) can be 2nd December 2022 but actual should be 12nd February 2022, especially there are many rows with different date format in single column. 

Thus, the suggested DAX cannot handle it effectively. What we can do to solve this besides mannually change it in Excel?

View solution in original post

9 REPLIES 9
TheoC
Super User
Super User

Hi @alvin199 

 

If you don't manage to get the other solutions to work, you can create a Calculated Column as follows:

 

Date Correction = 

VAR _DD = VALUE ( LEFT ( 'Table'[Date] , 2 ) )
VAR _MM = VALUE ( MID ( 'Table'[Date] , 4 , 2 ) )
VAR _YYYY = VALUE ( RIGHT ( 'Table'[Date] , 4 ) )

RETURN

IF ( _MM > 12 , DATE ( _YYYY , _DD , _MM ) , DATE ( _YYYY , _MM , _DD ) )

Outputs per below:

 

TheoC_0-1643957184773.png

Basically, the above formula checks the middle to determine if the month is greater than 12 which creates a switch.  The only issue you will have is that if you have a large dataset and there is many of these date errors, it's likely that irrespective of what approach you take, there may be the situation that arises where you have 11/3/2022 which may be 3 November 2022 or 11 March 2022.  Please take caution to this.

 

All the best.

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Hi @TheoC 

 

Thank you for the suggestion. 

 

I have 1 point not understand. In line 9, the Then and Else statement does not reflect in the output. This means the Column value does not start with YYYY.

 

@alvin199 the THEN / ELSE uses DATE which to format the text to a date. DATE function is used YYYY , MM ,DD but translates to DD/MM/YYYY or aligns to Date format in Power BI.

 

Hope that makes sense. Please test the formula.

 

Thank you.

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Thanks for your explanation. The IF Then statement is how the year, month and day sequence based on DATE formula and the output display is based on our compute setting. 

 

As you have raised caution regarding the display result may be have conflict. For example, 02/12/2022 (text) can be 2nd December 2022 but actual should be 12nd February 2022, especially there are many rows with different date format in single column. 

Thus, the suggested DAX cannot handle it effectively. What we can do to solve this besides mannually change it in Excel?

@alvin199 DAX does not do miracles and it cannot "guess" which rows in your source file are meant to be days or months, especially when there is a chance that they can be either or.  The only way that you can sort this out is by cleaning up the raw data file.

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

@TheoC 

 

Alright. Thanks for the advise. 

 

It is a good practise for me to think, act and learn from you. 

Really appreciate your responses. 

amitchandak
Super User
Super User

@alvin199 , first of all, has power bi taken it has date. Then you can use the format of your choice using the format option.

 

I doubt it is still text or power bi has not taken it in the current format

 

refer

DD/MM/YYYY to MM/DD/YYYY
date(year( right(DD__MM__YY[date],4)), month(mid(DD__MM__YY[date],4,2)) ,day(left(DD__MM__YY[date],2)))

 

MM/DD/YYYY to DD/MM/YYYY
date(year( right(DD__MM__YY[date],4)), month(left(DD__MM__YY[date],2)),day(mid(DD__MM__YY[Version_Id],4,2)) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I am able to extract the date for the first 3 row but it display weird result on the 4th row. 

 

alvin199_0-1643955917505.png

 

If need to use IF Then statement, not sure how to incorporate it correctly 

alvin199_0-1643956856286.png

 

@amitchandak 

 

I encounter errror. 

alvin199_0-1643952752050.png

The original data type for Date column is text by Power BI. 

Also, using this formula will create error for the 4th row as its format is not the same with the first 3 row.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.