Forum Discussion

manoj_0911's avatar
manoj_0911
Icon for Post Prodigy rankPost Prodigy
2 years ago
Solved

Help Needed: Converting Seconds/Milliseconds Field to HH:MM:SS Format in Power BI

Hi everyone,

 

I hope you're all doing well. I'm currently working on a project where I need to convert a field containing seconds/milliseconds into the HH:MM:SS format in Power BI. In Tableau, I successfully used the following formula:

```
Available (AVG) = AVG([Available])
```
Available (AVG) (HH:MM:SS) =
IIF([Available (AVG)] % 60 == 60, 0, [Available (AVG)] % 60) +
IIF(INT([Available (AVG)] / 60) % 60 == 60, 0, INT([Available (AVG)] / 60) % 60) * 100 +
IIF(INT([Available (AVG)] / 3600) % 24 == 0, 0, INT([Available (AVG)] / 3600) % 24) * 10000
```

However, when trying to replicate this in Power BI, I encountered some issues with the accuracy of the results. Here's the DAX expression I used:

```
AverageAvailableTime =
DIVIDE(
SUM('STATUS_SUBHOUR_V'[AVAILABLE]),
COUNTROWS('STATUS_SUBHOUR_V')
)
```
AverageAvailableTimeFormatted =
FORMAT(
TIME(
INT([AverageAvailableTime] / 3600), // Hours
INT(MOD([AverageAvailableTime] / 60, 60)), // Minutes
INT(MOD([AverageAvailableTime], 60)) // Seconds
),
"HH:mm:ss"
)
```

The results I'm getting in Power BI are not matching what I achieved in Tableau. Could someone please guide me on the correct approach to convert a seconds/milliseconds field to HH:MM:SS format in Power BI?

Any help or insights would be greatly appreciated.

 

Thank you!

Manoj Prabhakar

1 Reply