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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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:

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

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
Super User

@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...
10 REPLIES 10
Helper I

@Greg_DecklerI am having an issue with longer durations.

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

Helper I

@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:

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"

Super User

@ 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...
Helper I

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

Super User

@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...
Helper I

@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.

Super User

@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...
Helper I

@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?

Super User

@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...
Helper I

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.

## Helpful resources

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Join our Community Sticker Challenge

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

#### Power BI Monthly Update - July 2024

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

#### Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors