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
Anonymous
Not applicable

Convert ddmmmyyy string to datatype date

I have a column with string data like this: "Message Age_28Apr2020.xlsx"

 

I am using this DAX to extract the date information into a separate real date column:

Date =
var FirstDelimiter = FIND("_";Table[Source.Name];1)
var SecondDelimiter = FIND(".";Table[Source.Name];FirstDelimiter +1)
return
MID(Table[Source.Name];FirstDelimiter +1; SecondDelimiter - FirstDelimiter -1)
 
This results in 28Apr2020 but I cannot convert this to the data type "date", Power BI and the datevalue function can't recognize this as a string date. I don't care about the format I just need to convert this tho date format so that I can create a relationship with my calendar table (and the other tables).  
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Recreate this column like. You should be able to change data type to date

new column = left([Datecol],2) &"-"& mid([Datecol],3,3)&"-"& right([Datecol],4)

28-Apr-2020

View solution in original post

2 REPLIES 2
Ivan
Regular Visitor

Thank you for the formula. Any idea why I'm unable to change the data type to 'Date'? It gives me an #Error.

amitchandak
Super User
Super User

@Anonymous , Recreate this column like. You should be able to change data type to date

new column = left([Datecol],2) &"-"& mid([Datecol],3,3)&"-"& right([Datecol],4)

28-Apr-2020

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.