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
yossi
New Member

Text To Date randomly switches days and months

I have columns that are looked up from different source, so I had to convert them into text in order to be able to look them up. Then when they were looked up I did new column with text to date using "dd/mm/yyyy". But it randomly uses format mm/dd and dd/mm.

 

I want to have them all as "dd/mm/yyyy". I am lost.

 

yossi_0-1679405587685.png

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

7 REPLIES 7
Ahmedx
Super User
Super User

Column = VAR _patch =SUBSTITUTE([Date],"/","|")
         VAR _Result =
          DATE(PATHITEM(_patch,3),PATHITEM(_patch,2),PATHITEM(_patch,1))
RETURN
if ( NOT ISBLANK([Date]),_Result,0)
Ahmedx
Super User
Super User

Screen Capture #706.pngScreen Capture #707.pngScreen Capture #708.pngScreen Capture #709.png

Thank you for your time and helping me, Ahmad. I was able also to solve it with quicker (or easier) formula:

Submission = IF(

    Source[Submission TEXT] = "",0,

    DATE(

        RIGHT(Source[Submission TEXT],4),

        MID(Source[Submission TEXT],4,2),

        LEFT(Source[Submission TEXT],2)))

yossi
New Member

yossi_0-1679410358725.png

 

Ahmedx
Super User
Super User

Screen Capture #700.png

Ahmedx
Super User
Super User

Screen Capture #699.png

But how do I do that in Dax? Lookup is done in Table tab in Dax, so I don't have these columns in Power Query.

 

To convert I used this formula:

 

Submission Date = IF(

    Source[Submission TEXT] = "",0, DATEVALUE(FORMAT(Source[Submission TEXT], "DD/MM/YYYY")))

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.