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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
KaiPonte
Helper I
Helper I

Help Formatting Time from Minutes

In the report I'm building, I'm given a time duration in minutes.  I want to convert it to days hours:minutes.  (I don't care about seconds.)

Based on examples I saw here, I have teh following DAX forumula:

 

Time = VAR Elapsed_Time = SELECTEDVALUE('Query1'[SyncTime]) --Get Duration from Current Row
VAR days = INT(Elapsed_Time) /900 --calculate whole days
VAR hrs = (INT(Elapsed_Time) /900/60) --calculate whole hours
VAR mins = hrs * 60 --calculate whole minutes
RETURN
days & " d " & FORMAT(hrs,"00") & " h " & FORMAT(mins,"00") & " m "
 
What comes back is not how I'd format it. For example, for the duration, 31991 minutes, I get the result 35.545555555556 d 01 h 36 m
Now I think the time calculation is correct, but I only want whole days.  I expect it to be 35 d 01 h 36 m
 
What am I doing wrong?  Thanks in advance!
 
 
 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@KaiPonte 

the close branket is in the wrong position. you can try to move it to the end.

VAR days = INT(Elapsed_Time /900 )





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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
perfectreign
Frequent Visitor

Thank you all!!!  I have it now.

 

Screenshot 2023-12-07 093520.png

gmsamborn
Solution Sage
Solution Sage

Hi @KaiPonte 

 

The following is a calculated column to do your conversion.

 

Fmt = 
VAR _TotMin = [Minutes]
VAR _x1 = _TotMin / 1440
VAR _Days = INT( _x1 )
VAR _Remainder = _x1 - _Days
VAR _Hrs = INT( _Remainder * 24 )
VAR _Mins = _TotMin - ( ( _Days * 24 ) +  _Hrs ) * 60
RETURN
    _Days & " d " & _Hrs & " h " & _Mins & " m"

 

 

I hope you are able to adapt this.

 

Formatting Time from Minutes.pbix

 

 

 

ryan_mayu
Super User
Super User

@KaiPonte 

the close branket is in the wrong position. you can try to move it to the end.

VAR days = INT(Elapsed_Time /900 )





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

Proud to be a Super User!




That was perfect, thank you!  I now have what I wanted in the report.  You can see in the image that my time now is measured in days, hours, and minutes.  That's perfect. (I don't need seconds.)

 

Screenshot 2023-12-12 092921.png

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.