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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ok_kpop
Frequent Visitor

Text to Date Formula Help

Every month I load in an excel file into my Power BI template. The spreadsheet has a column formatted as text which represents the date and looks something like "80123" which represents August 1, 2023. To convert the text to date format of 8/01/2023, I have the formula as 

 

= Table.AddColumn(#"Changed Type1", "Custom", each Text.Combine({Text.Start(Text.From([Date], "en-US"), 1), "/", Text.Middle(Text.From([Date], "en-US"), 1, 2), "/2023"}), type text) 

 

But, whe I load in a file for months that have two digits for the month such as "100123" the formula only works the same if I change it to = Table.AddColumn(#"Changed Type1", "Custom", each Text.Combine({Text.Start(Text.From([Date], "en-US"), 2), "/", Text.Middle(Text.From([Date], "en-US"), 2, 2), "/2023"}), type text) 

 

Is there perhaps a different formula I can use so that I don't have to keep changing it where it can convert the text to the correct date format regardless how many digits the month has?

2 REPLIES 2
Ahmedx
Super User
Super User

pls try this

Date.FromText( Text.PadStart(Text.From(
    [date]),6,"0"), [Format = "MMddyy"])

Screenshot_3.png

HotChilli
Super User
Super User

There will be another formula but why don't you pad the text using :

Text.PadStart(theColumn, 6, "0")

and use the 2nd formula on everything.

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.