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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Grizzlydad
Helper I
Helper I

Custom Column Formula Time to total minutes only

Hi all

Hopefully this is very simple to do, I want the Mins column below to have a time value shown in minutes only so where there is an hour value it should count as total minutes,  most of them in the column are minutes only.  How do I write a custom column formula to do that.  In the example below 02:19 should show as 139 (minutes) and 01:12 should show as 72 (minutes).

 

All the best

 Time   Mins                               

02:19132
01:1272
03:54234
23:451425
2 ACCEPTED SOLUTIONS

@Grizzlydad 

Copy the previous code in a blank query so that you can see the steps and from there adapt it to what you have.

The code for the calculated column is:

Number.From(Text.Split([Time],":"){0})*60 + Number.From(Text.Split([Time],":"){1})

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

dax
Community Support
Community Support

Hi @Grizzlydad , 

You could refer to @AlB 's suggestion. I think you might use code like below in custom column, so you will get table instead of column value.

742.PNG

You  need to change this like below

743.PNG

Check code in Advanced Editor to see whether is similar to @AlB 's code. Or you could upload your M code, then we will try to test this in my environment

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
AlB
Super User
Super User

Hi @Grizzlydad 

Assuming your Time column is of type text, add a custom column:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjCyMrRUitUBsgytDI0gLGMrUxMwy8jYysRUKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
    
   #"Added Custom" = Table.AddColumn(Source, "Mins", each Number.From(Text.Split([Time],":"){0})*60 + Number.From(Text.Split([Time],":"){1}) )
in
    #"Added Custom"

 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Thanks but this just returned Table as the entrie in the custom column?

@Grizzlydad 

Copy the previous code in a blank query so that you can see the steps and from there adapt it to what you have.

The code for the calculated column is:

Number.From(Text.Split([Time],":"){0})*60 + Number.From(Text.Split([Time],":"){1})

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Hiya, thnaks again but still returns Table in Mins column?

The column name for changed into mins is Time taken for response

 
 

RoadworksPowerBi.PNG

dax
Community Support
Community Support

Hi @Grizzlydad , 

You could refer to @AlB 's suggestion. I think you might use code like below in custom column, so you will get table instead of column value.

742.PNG

You  need to change this like below

743.PNG

Check code in Advanced Editor to see whether is similar to @AlB 's code. Or you could upload your M code, then we will try to test this in my environment

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors