Forum Discussion
Assistance required: Converting seconds measures
- 7 years ago
See if this article helps. https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486. But you probably want something along the lines of (as a column):
Column = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT([Value]/__secondsInDay) VAR __hours = INT(([Value]-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"
- 7 years ago
Hi Anonymous,
Rather than create a calculated column, you could new a measure instead still with above formula.
Measure = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT('arms_reach vw_mold_tracking'[Enabled]/__secondsInDay) VAR __hours = INT(([Enabled]-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"Best regards,
Yuliana Gu
See if this article helps. https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486. But you probably want something along the lines of (as a column):
Column = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT([Value]/__secondsInDay) VAR __hours = INT(([Value]-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"
- Anonymous7 years agoNot applicable
Thank You so Much Greg! It does what I want to do but it seems I under estimated the complexity of my end goal. I have a bar chart with the run time in seconds where I wanted to feed this into. I have scaled the bar chart by dividing the run time by 86400, so that it gives me a scale in days(be it decimal), But if I try to put this calculated column as a tooltip it wont give me the days and hours after summing all the run times on that day.
Any workaround for that? I'm thinking of changing the calculation so that instead of taking the 'enabled' measure, I have to create a new measure(sum of all runtimes for that particular date) which feeds into the below code.
Column 5 = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT('arms_reach vw_mold_tracking'[Enabled]/__secondsInDay) VAR __hours = INT(([Enabled]-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"- Greg_Deckler7 years agoCommunity Champion
Right, so you want the measure form, which should be something like:
Column = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT(SUM([Value])/__secondsInDay) VAR __hours = INT((SUM([Value])-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"
- Anonymous7 years agoNot applicable
Thank You so Much Greg! It does what I want to do but it seems I under estimated the complexity of my end goal. I have a bar chart with the run time in seconds where I wanted to feed this into. I have scaled the bar chart by dividing the run time by 86400, so that it gives me a scale in days(be it decimal), But if I try to put this calculated column as a tooltip it wont give me the days and hours after summing all the run times on that day.
Any workaround for that? I'm thinking of changing the calculation so that instead of taking the 'enabled' measure, I have to create a new measure(sum of all runtimes for that particular date) which feeds into the below code.
Column 5 = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT('arms_reach vw_mold_tracking'[Enabled]/__secondsInDay) VAR __hours = INT(([Enabled]-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"- v-yulgu-msft7 years agoMicrosoft Employee
Hi Anonymous,
Rather than create a calculated column, you could new a measure instead still with above formula.
Measure = VAR __secondsInDay = 86400 VAR __secondsInHour = 3600 VAR __days = INT('arms_reach vw_mold_tracking'[Enabled]/__secondsInDay) VAR __hours = INT(([Enabled]-(__days*__secondsInDay))/__secondsInHour) RETURN __days & " Days " & __hours & " Hours"Best regards,
Yuliana Gu
- Anonymous7 years agoNot applicable
Hi Greg_Deckler , how would you do this in dax if you were to include minutes and seconds as well? So, day, hour, minute, second.
Best,
Nils