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.

0

Solution to represent time in [h]:mm:ss format

Hi,

I have been facing this issue for quite a while. I went through some solutions in this forum and they did not serve my purpose.

My requirement is to not only represent time on each row, I have to aggregate total duration for the selected time range as well (selected on slicers) which can be a day, week(s) or month(s).

I have done the following to serve my purposes - I broke down calculation to Hours, minutes and seconds and then represent in format to be able to serve my purpose.

 

MEASURES - 

CALLTIMES = SUM(DURATIONINSECONDS)

HRS = TRUNC([CALLTIMES]/3600)

MINS = TRUNC((([CALLTIMES]/3600)-[HRS])*60,0)

SECS = TRUNC((((([CALLTIMES]/3600)-TRUNC([CALLTIMES]/3600))*60)-[MINS])*60)

TIMING = IF(LEN([HRS])=1,"0"&[HRS],[HRS])&":"&IF(LEN([MINS])=1,"0"&[MINS],[MINS])&":"&IF(LEN([SECS])=1,"0"&[SECS],[SECS])

 

This works perfectly for me for any selected time range, whether it is a day/month or months/week or weeks. I would not have to take a long route if there was formatting available in Power BI visuals, like we custom format in excel = [h]:mm:ss

 

I will he happy to know an easier solution if available.

Status: Delivered
Comments
v-haibl-msft
Employee

@ShrikantKhanna

 

Currently there is no built-in function to get your desired result directly. You DAX measures can be an alternative. You can also take a look at this great article posted by smoupre. And vote on following existing ideas.

 

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/8814178-field-of-duration-type

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/17961811-duration-managed-like-a-...

 

Best Regards,

Herbert

Vicky_Song
Impactful Individual
Status changed to: Delivered
 
ShrikantKhanna
Helper II

Thanks.