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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
monojchakrab
Resolver III
Resolver III

convert text string to date in power query

Hey Good people,

 

I am grappling with a queer problem right now...

 

I have received a bunch of excel sheets, monthwise, but the monthname is input as a text string. e.g. the month of April, in the excel sheet is entered as "Apr". I have tried to use Date.FromText, but that is returning an error and so is any attempt to change the type from text to Date thru' the UI.

 

Is there a workaround for this without having to go back to each of the excel sheets and cnage the format manually, before loading to PQ?

 

Any help appreciated as I have more than 60 worksheets to work thru' with this messy date format.

 

Thanks in advance

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @monojchakrab ,
yes, the implementation is a bit clumsy, as you have to cater for the number of days digits. The following works for me. Add a column with this formula (assuming your date values sit in column "Date"):

Date.FromText([Date], [Format = try "d MMM yyyy" otherwise "dd MMM yyyy", Culture = "de-DE"])

Please also check the file enclosed.



Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

2 REPLIES 2
ImkeF
Community Champion
Community Champion

Hi @monojchakrab ,
yes, the implementation is a bit clumsy, as you have to cater for the number of days digits. The following works for me. Add a column with this formula (assuming your date values sit in column "Date"):

Date.FromText([Date], [Format = try "d MMM yyyy" otherwise "dd MMM yyyy", Culture = "de-DE"])

Please also check the file enclosed.



Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks @ImkeF - tried this without luck. I am now trying to get the month from the file attribute which has a date created column and extract the month from there.

But appreciate the leg-up

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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