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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Date from text issue

Hey Guys, 

 

I have a set of data for training and I reach the point where I pivot the data properly yet, when I try to change the data type from text to date format (by changing type or using the date from text function it always returns error)

 

any Idea how to fix this ??

Mo1995_0-1669170196695.png

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

Date.From(Text.Combine(Splitter.SplitTextByAnyDelimiter({"st ","nd ","rd ","th "})([Attribute]),"-"))

View solution in original post

5 REPLIES 5
wdx223_Daniel
Super User
Super User

Date.From(Text.Combine(Splitter.SplitTextByAnyDelimiter({"st ","nd ","rd ","th "})([Attribute]),"-"))

Anonymous
Not applicable

Worked like magic
don't wanna bother, but can u tell me what was I doing wrong and how u wrote this formula, I'm a newbie in M

text with "st ","nd ","rd ","th " can not be recognized as a date,  so you must replace them with "-".

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could try it.

1.replace "," to ""

vyalanwumsft_0-1669271249693.png

2.add custom column.

Date.FromText(
Text.Middle(Text.SplitAny([Hours], " "){0},0,
    Text.Length(Text.SplitAny([Hours], " "){0})-2)
    & "-"&Text.SplitAny([Hours], " "){1}  
    & "-"&Text.SplitAny([Hours], " "){2})

vyalanwumsft_1-1669271290788.png

The final show:

vyalanwumsft_2-1669271308831.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ronrsnfld
Super User
Super User

You need to remove the ordinal suffixes.

Something like:

    #"Convert to Date" = Table.TransformColumns(#"Previous Step", {
        "Attribute", each Date.From(List.Min(List.Accumulate({"st","nd","rd","th"},{}, (state, current)=>
            state & {Text.Replace(_,current,"")}))), type date
    })

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors