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
delphinecarnet
Frequent Visitor

Number of Hours to Days/Hours/Minutes FORMAT don't convert properly, HELP!

I calculated the hours to days in Excel vs PowerBi and do not get the same results.

I'm averaging the number of hours + format it in a days/ hours/ minutes format

 

THANKS!

Here is the SCREEN 1.pngSCREEN 2.pngSCREEN 3.png

 

 

 

Avg Time = 

VAR 
total_hours = 

    SUMX( 

        Sheet2, 

        HOUR(Sheet2[Responses time]) +
MINUTE(Sheet2[Responses time])/60

)

VAR 
Daystotal = Total_hours/24

VAR 
DaysInt = TRUNC(DaysTotal)

VAR 
Hourstotal = (DaysTotal - 
DaysInt)*24

VAR 
HoursInt = TRUNC(HoursTotal)

VAR 
MinutesTotal = (HoursTotal - 
HoursInt)*60

VAR 
MinutesInt = TRUNC(MinutesTotal)

VAR 
SecondsTotal = ROUND(MinutesTotal -
MinutesInt*60,0)

RETURN

DaysInt&"d, "&FORMAT(HoursInt,"00")&"h, "&FORMAT(MinutesInt,"00")&"m, "

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @delphinecarnet ,

 

Here are the steps you can follow:

1. Create measure.

Avg Time =
VAR OverTimeHours = [Average of Respones time]
VAR Days = INT ( OverTimeHours / 24 )
VAR Hours = INT ( OverTimeHours - Days * 24 )
VAR Minutes = ROUND ( MOD ( OverTimeHours, 1 )* 60 , 0)
RETURN
Days & " Days " & Hours & " Hours " & Minutes & " Minutes"

2. Result:

vyangliumsft_0-1670563248633.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @delphinecarnet ,

 

Here are the steps you can follow:

1. Create measure.

Avg Time =
VAR OverTimeHours = [Average of Respones time]
VAR Days = INT ( OverTimeHours / 24 )
VAR Hours = INT ( OverTimeHours - Days * 24 )
VAR Minutes = ROUND ( MOD ( OverTimeHours, 1 )* 60 , 0)
RETURN
Days & " Days " & Hours & " Hours " & Minutes & " Minutes"

2. Result:

vyangliumsft_0-1670563248633.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

FreemanZ
Super User
Super User

how does your data in column [Responses time] look like? 

Customer NoResponses time
1444790528
144479053
144479050
1444790524
14447905109
14447905165
1444790585
144479054
14447905909
14447905353
144479053
14447905170
14447905190
14447905454
144479053
14447905568
14447905302
14447905865
1444790582
1444790531
1444790525
1444790545
1444790524
1444790293
144479020
1444790215
14447902147
144479020
1444790228
1444790268
144479022
144479020
144479020
14447902168
1444790242
14447902162
14447902155
14447902139
14447902354
144479020
1444790223
1444790291
1444790270
14447902112
14447902931
1444790272
14447902135
1444790243
144479022
1444790219
144479021,053
1444790219
144479023
144479020
14447902233
144479020
144479020
1444790227
144479021
144479020
14447902105
1444790243
14447902328
14447902161
144479022
144479020
1444790248
144994170
1449941725
14499417927
144994172,163
144994173
14499417119
14499417119
144994170
144994171,772
1449941766
1449941725
1449941743
1449941746
14499417192
144994170
144994170
144994170
14499417141
144994170

it seems the response time is in minute, or?

try change the SUMX part to

SUMX(Table2, Table2[Response Time]/60)

?

You actually gave me a big hint on the solution.

I have found this DAX on a blog, but it was meant for the a number of days rather than a number of hours.

Here is the DAX that works:

Avg Time =

VAR
Total_hours = AVERAGE(Database[OSRT (Customer View)(Hrs)])

VAR
Daystotal = Total_hours/24

VAR
DaysInt = TRUNC(Daystotal)

VAR
Hourstotal = (Total_hours -
(DaysInt*24))

VAR
HoursInt = TRUNC(Hourstotal)

VAR
Minutestotal = (Hourstotal -
HoursInt)*60

VAR
MinutesInt = TRUNC(Minutestotal)

RETURN

DaysInt&"days "&FORMAT(HoursInt,"00")&"hours "&FORMAT(MinutesInt,"00")&"minutes"

 

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.