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

Extract number values from one column to multiple columns

Hello!

Can anybody help me to transform the columns values (Date Difference) which are not constant into multiple columns as shown below: Its an urgent request from my client who need exact 4 columns as output for all the time frames. Thanks in advance.

 

Inputoutput   
Date differenceWeek(w)Day(d)hours(h)minutes(m)
1w 5d 18h 54m151854
1d 1h 3m-113
2h 20m--220
10m---10
3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMixXME1RMLTIUDA1yVWK1QGKALkZCsYQjlGGgpEBVBxKG5UbZygoKBgZQbiWKUCOoQWQEwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date difference" = _t]),

    Split = Table.AddColumn(Source, "Split",
        each let
                txt = Text.Remove([Date difference], " "),
                chars = Text.Select(txt, {"a".."z"})
            in
                Record.FromList(List.RemoveLastN(Text.SplitAny(txt, chars)), Text.ToList(chars))
    ),
    #"Expanded Split" = Table.ExpandRecordColumn(Split, "Split", {"w", "d", "h", "m"})
in
    #"Expanded Split"

 

CNENFRNL_0-1656350400140.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @CNENFRNL ,

Thanks for the quick reply,

 

As I am new to power BI, Can you please let me the steps to execute your code (or) where to copy your code.

Can i copy your code to custom column ? if so then I am getting values as table, table... in the new column. 

PLease guide me. thanks

ryan_mayu
Super User
Super User

@Anonymous 

maybe you can transform the data in PQ. 

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors