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
Lisa-Eagle
Helper I
Helper I

Viewing Minutes (Decimal) to Duration with total

Hello!

 

I have a report from our LMS showing viewing minutes as a decimal. I would like to create a new column that converts the decimal minutes to a duration where I see the total duration per course as well.

 

I have tried various suggested measures as well and got a duration to show, but then I wasn't able to get a total.

 

Any suggestions will be so appreciated.

 

In Excel it looks like this:

LisaEagle_0-1668780878862.png

 

This is where I can get to inside my Power BI file:

LisaEagle_1-1668780954697.png

The Viewing duration is based on a measure:

Viewing Duration2 = FORMAT([Viewing Seconds]/86400,"Long Time")  
 
I have been struggling with this one.
 
Thank you,
Lisa

 

1 ACCEPTED SOLUTION

@Lisa-Eagle Maybe:

  VAR seconds = ROUND( MOD ( MOD ( total, 3600 ), 60 ), 2 )


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

10 REPLIES 10
Lisa-Eagle
Helper I
Helper I

@Greg_DecklerI am having an issue with longer durations.

 

LisaEagle_0-1676387297192.png

I tried to adapt the measure as follows but it didn't work. I would like the hours to not show more than 24hrs and for the days number to adapt accordingly.

 

Total Duration Measure =
VAR total =
    AVERAGE('Parsons Unique User Sign Ins'[Seconds] )
VAR weeks =    
     INT (total /604800 )
VAR days =
    INT ( total / 86400 )
VAR hours =
    INT ( total / 3600 )
VAR minutes =
    INT ( MOD ( total, 3600 ) / 60 )
VAR seconds =
ROUNDUP( MOD ( MOD ( total, 3600 ), 60 ), 0 )
   RETURN
    weeks & " wks "
        & days
        & " days "
        &  hours
        &" hrs "
        & minutes
        & " min "
        & seconds
        & " sec"

 

Any ideas what I can try?

 

Thanks

Lisa Taylor

@Greg_Deckler I am still experiencing some issues with my duration and hoping you can point me in the right direction.

 

Issue 1 is that I would like to adapt the measure to only show a total of 24 hours as there are 24 hours in a day. 

When I try to show a total duration I get the following: 

LisaEagle_0-1681209797683.png

Issue 2 is if I select to filter my table by group my duration measure is not maintained and I only get blanks dhms.

Current duration measure is:

CE Course Completion Duration =
VAR total =
    SUM ('Course Enrollments'[# of Seconds to Completion] )
VAR days =
    INT ( total / 86400 )
VAR hours =
    INT ( total / 3600 )
VAR minutes =
    INT ( MOD ( total, 3600 ) / 60 )
VAR seconds =
ROUNDUP( MOD ( MOD ( total, 3600 ), 60 ), 0 )
   RETURN
    days & " d "
        &  hours
        &" h "
        & minutes
        & " m "
        & seconds
        & " s"
   
Greg_Deckler
Super User
Super User

@Lisa-Eagle Chelsie Eiden's Duration - Microsoft Power BI Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Not sure where I am going wrong with this?

 

LisaEagle_0-1668784237206.png

 

@Lisa-Eagle Since that is a Column instead of a Measure, ditch the SUM in your Duration variable and just reference the column directly.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thank you for your help thus far. I've managed to get the correct duration to display using your code from 2016.

See below screenshot. My question is now how can I show a sum of this column similar to the total shown under viewing minutes in my table.

You are a life saver, thanks again.

 

LisaEagle_2-1669113044278.png

@Lisa-Eagle First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thank you for sharing those links. I so wish this totals issue was easier.

 

I have managed to get a total duration to show using the measure in below image. This is the closest I have gotten to what I would like to visualise. Only challenge now is how to adapt this measure so that seconds is rounded up to 2 places. Any ideas on that one please?

 

LisaEagle_0-1669292913845.png

 

@Lisa-Eagle Maybe:

  VAR seconds = ROUND( MOD ( MOD ( total, 3600 ), 60 ), 2 )


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you @Greg_Deckler that worked. I managed to adapt my measure to include days as well and used roundup for the seconds. Pretty cool. I am very grateful to you and this forum.

LisaEagle_0-1669299386475.png

 

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