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! Request now

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
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.

Top Kudoed Authors