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
Anonymous
Not applicable

How to calculate average and total time on Power BI?

Hello, I want to calculate the sum and average of the solution time of the help desk application requests on Power BI. However, the collection of hour information over 24 hours causes errors in average. How can I include times over 24 hours in total and average?

I would be glad if you could help.

 

Technician

Time

John

00:03:20

Jack

00:30:29

Jessica

01:02:42

Justin

04:01:24

Jonathan

34:02:42

Jimmy

04:03:16

Jackson

08:04:03

Jonhson

130:04:33

Jacob

67:54:34

 

Average Time = ?

Total Time = ?

 

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

c1.png

 

You may create two measures as below.

 

Sum = 
var tab = 
ADDCOLUMNS(
    ALL('Table'),
    "Result",
    var f1 = SEARCH(":",[Time])
    var f2 = SEARCH(":",[Time],f1+1)
    var h = LEFT([Time],f1-1)
    var m = MID([Time],f1+1,f2-f1-1)
    var s = MID([Time],f2+1,LEN([Time])-f2)
    var totalsecond = 3600*h+60*m+s
    return
    totalsecond
)
var re = 
SUMX(
    tab,
    [Result]
)
var hh = INT(DIVIDE(re,3600))
var mm = INT(DIVIDE(MOD(re,3600),60))
var ss = INT(MOD(MOD(re,3600),60))
return
hh&":"&mm&":"&ss

 

 

 

Avg = 
var tab = 
ADDCOLUMNS(
    ALL('Table'),
    "Result",
    var f1 = SEARCH(":",[Time])
    var f2 = SEARCH(":",[Time],f1+1)
    var h = LEFT([Time],f1-1)
    var m = MID([Time],f1+1,f2-f1-1)
    var s = MID([Time],f2+1,LEN([Time])-f2)
    var totalsecond = 3600*h+60*m+s
    return
    totalsecond
)
var re = 
AVERAGEX(
    tab,
    [Result]
)
var hh = INT(DIVIDE(re,3600))
var mm = INT(DIVIDE(MOD(re,3600),60))
var ss = INT(MOD(MOD(re,3600),60))
return
hh&":"&mm&":"&ss

 

 

Result:

c2.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Hi @v-alq-msft,

 

Thank you very much for the information you provide. It was really useful. However, there is one thing I cannot do. There is a time value for each request by technicians in the list here. How can I show the sum and average of these values per technician? It can be done Pivot Table on Excel, but I could not do it on Power BI. In short, I would like to show the number of requests on the basis of technicians and the average of the solution times, as seen on Pivot Table.

 

I would really appreciate if you can help.

 

PT.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Excel file in "We Transfer" 

Hi, @Anonymous 

 

I am not clear about the expected result. What is raw data like? Could you please explain furthter with some sample data? Thanks.


Best Regards

Allan

Anonymous
Not applicable

Hi, 

 

I couldn't manage to upload the data file here. However, in my previous post, I uploaded it to "we transfer" and shared it. The situation I am trying to explain is displayed as a pivot in the file included in the transfer.

 

Can you download and review the file I shared? The detail I want to explain appears in the excel file as a pivot table. The other sheet of Excel contains data.

 

Thank you so much.

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.