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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Convert Minutes to Hrs and minutes and make it sum

Hi All,

 

I am tryiing tp convert my table which is stored in minutes

sample

 Number            Mins

     3                    60

     4                    80 

 

Now I want to convert them into 1hr 0mins and 1 hr 20 mins and also want it to be able to summarize them as SUM

so in table, I can get 2 hrs 20 mins

I have tried 2 following methods, which converts the whole thing into Text and is no longer summable
Method 1

let

DecHrs = [TOTAL EXPECTED MINS]/60,

WholeHrs = Number.Round(DecHrs),

Minutes = ((DecHrs)-(WholeHrs))*60,

WholeMin = (DecHrs) - (Minutes),

FormattedTime =  Number.ToText(WholeHrs) & " hrs " & Number.ToText(Minutes) & " mins"

in

    FormattedTime)

Method 2 

let

        TotalMinutes = [TOTAL EXPECTED MINS],

        Hours = TotalMinutes / 60, WholeHrs = Number.Round(Hours),

        Minutes = (Hours- (WholeHrs))*60,

        FormattedTime = Text.PadStart(Text.From(WholeHrs), 2, "0") & ":" & Text.PadStart(Text.From(Minutes), 2, "0")

    in

        FormattedTime

Apart from that, I have thought of making 2 separate columns and using them, But feels lengthy for multiple uses

Appreciate the assistance in getting the solution and thank in advance

2 ACCEPTED SOLUTIONS

Anonymous
Not applicable

After summing, if anyone had negative values like I did, try this method that worked for me. Other methods made negative 1.5 to 2 on rounding.

TASK AVAILABLE HRS LEFT = 
VAR _all = SUM([MIN Table])/ 60
VAR _sign = IF(_all < 0, -1, 1)
VAR a_all = ABS(_all)
VAR _Hrs = INT(a_all)
VAR _Min = ROUND((a_all - _Hrs) * 60, 0)
RETURN 
IF(_sign < 0, "-", "") & _Hrs & ":" & FORMAT(_Min, "00")

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

After summing, if anyone had negative values like I did, try this method that worked for me. Other methods made negative 1.5 to 2 on rounding.

TASK AVAILABLE HRS LEFT = 
VAR _all = SUM([MIN Table])/ 60
VAR _sign = IF(_all < 0, -1, 1)
VAR a_all = ABS(_all)
VAR _Hrs = INT(a_all)
VAR _Min = ROUND((a_all - _Hrs) * 60, 0)
RETURN 
IF(_sign < 0, "-", "") & _Hrs & ":" & FORMAT(_Min, "00")

 

Ahmedx
Super User
Super User

pls try this

Screenshot_2.pngScreenshot_3.png

Anonymous
Not applicable

Would this have the same issue as @ryan_mayu  or suppose if my minutes is 2748 it would result in 45(hh):48(nn)?

pls try this

Screenshot_1.png

ryan_mayu
Super User
Super User

@Anonymous 

you can try this

Column = time(int('Table'[Min]/60),mod('Table'[Min],60),0)

11.PNG

 

however, the problem is if the hour is more than 23, it will display incorrect.

maybe you can try to add all mins, and transfer to the text type at last.





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

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.