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

Splitting Column in time format as 1h 20m ect

Hi all,

 

I have a column that is formatted like this

Elapsed Time
1h

8h 30m

15m
2h 22m
 

 

I would like to split the column by hours and minutes. 

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

Using Power Query: (assuming h and m are sequential in positions)

 

let
    Source = Table,
    #"Added Conditional Column" = Table.AddColumn(Source, "Hours", each 
        if Text.Contains([Elapsed Time], "h") then Text.BeforeDelimiter([Elapsed Time], "h")
        else if not Text.Contains([Elapsed Time], "h") then null
        else null
        ),
    #"Added Conditional Column 2" = Table.AddColumn(#"Added Conditional Column", "Minutes", each 
        if Text.Contains([Elapsed Time], "h") and Text.Contains([Elapsed Time], "m") then Text.BetweenDelimiters([Elapsed Time], "h", "m")
        else if Text.Contains([Elapsed Time], "m") then Text.BeforeDelimiter([Elapsed Time], "m")
        else if not Text.Contains([Elapsed Time], "m") then null
        else null) 
in
    #"Added Conditional Column 2"

 

 

Output:

sevenhills_0-1670367900895.png

 

View solution in original post

1 REPLY 1
sevenhills
Super User
Super User

Using Power Query: (assuming h and m are sequential in positions)

 

let
    Source = Table,
    #"Added Conditional Column" = Table.AddColumn(Source, "Hours", each 
        if Text.Contains([Elapsed Time], "h") then Text.BeforeDelimiter([Elapsed Time], "h")
        else if not Text.Contains([Elapsed Time], "h") then null
        else null
        ),
    #"Added Conditional Column 2" = Table.AddColumn(#"Added Conditional Column", "Minutes", each 
        if Text.Contains([Elapsed Time], "h") and Text.Contains([Elapsed Time], "m") then Text.BetweenDelimiters([Elapsed Time], "h", "m")
        else if Text.Contains([Elapsed Time], "m") then Text.BeforeDelimiter([Elapsed Time], "m")
        else if not Text.Contains([Elapsed Time], "m") then null
        else null) 
in
    #"Added Conditional Column 2"

 

 

Output:

sevenhills_0-1670367900895.png

 

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