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
deemon1981
Regular Visitor

Average response time and callout duration

Hi,

 

I am new to Power BI and currently working on my 1st project.  I have got stuck on the last hurdle and can't seem to figure out how to resolve my issue.  I have imported a single excel spreadsheet into Power BI and want to make a simple table that takes data from 3 columns (response type has 3 options PRE, No Gas, Meter Fault) and give me the average reponse time and callout duration for each of the 3 response types - PRE, No gas and meter fault jobs.

 

Capture.PNG

As you can see it is listing every time per row rather than give me an average for each response type.  I tried AVERAGEX but it would only give me the option of a count total.

 

I would be really grateful if someone could point me in the right direction with this.

 

Thanks,

David

6 REPLIES 6
Icey
Community Support
Community Support

Hi @deemon1981 ,

 

Sorry, Power BI does support duration formats now. 

Create your measure like so:

Response Time in Second Measure 2 = 
VAR Hours =
    TRUNC ( [DateDiffSeconds Measure]/3600 )
VAR Minutes =
    TRUNC ( ( [DateDiffSeconds Measure] - Hours * 3600 ) / 60 )
VAR Seconds = [DateDiffSeconds Measure]- Minutes * 60 - Hours * 3600
RETURN
Hours * 10000 + Minutes * 100 + Seconds

 

And then change the data format manually.

duration.gif

 

And then create visuals:

bar2.PNGbar.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

Icey
Community Support
Community Support

Hi @deemon1981 ,

 

How about this?

 

If you want to create columns, try this:

DateDiffSeconds = DATEDIFF ( [Occurrent Time], [Response Time], SECOND )
Response Time in Second = 
VAR Hours =
    TRUNC ( [DateDiffSeconds] / 3600 )
VAR Minutes =
    TRUNC ( ( [DateDiffSeconds] - Hours * 3600 ) / 60 )
VAR Seconds = [DateDiffSeconds] - Minutes * 60 - Hours * 3600
VAR Result =
    Hours & ":"
        & FORMAT ( Minutes, "00" ) & ":"
        & FORMAT ( Seconds, "00" )
RETURN
    CONVERT ( Result, DATETIME )
Call out duration = 
VAR Avg_Seconds =
    CALCULATE (
        AVERAGEX ( 'Table', [DateDiffSeconds] ),
        ALLEXCEPT ( 'Table', 'Table'[Response Type] )
    )
VAR Hours =
    TRUNC ( Avg_Seconds / 3600 )
VAR Minutes =
    TRUNC ( ( Avg_Seconds - Hours * 3600 ) / 60 )
VAR Seconds = Avg_Seconds - Minutes * 60 - Hours * 3600
VAR Result =
    Hours & ":"
        & FORMAT ( Minutes, "00" ) & ":"
        & FORMAT ( Seconds, "00" )
RETURN
    CONVERT ( Result, DATETIME )

 

If you want to create measures, try this:

DateDiffSeconds Measure = DATEDIFF(MAX('Table'[Occurrent Time]),MAX('Table'[Response Time]),SECOND)
Response Time in Second Measure = 
VAR Hours =
    TRUNC ( [DateDiffSeconds Measure]/3600 )
VAR Minutes =
    TRUNC ( ( [DateDiffSeconds Measure] - Hours * 3600 ) / 60 )
VAR Seconds = [DateDiffSeconds Measure]- Minutes * 60 - Hours * 3600
VAR Result =
    Hours & ":"
        & FORMAT ( Minutes, "00" ) & ":"
        & FORMAT ( Seconds, "00" )
RETURN
    CONVERT ( Result, DATETIME )
Call out duration Measure =
VAR Avg_Seconds =
    CALCULATE (
        AVERAGEX ( 'Table', [DateDiffSeconds Measure] ),
        ALLEXCEPT ( 'Table', 'Table'[Response Type] )
    )
VAR Hours =
    TRUNC ( Avg_Seconds / 3600 )
VAR Minutes =
    TRUNC ( ( Avg_Seconds - Hours * 3600 ) / 60 )
VAR Seconds = Avg_Seconds - Minutes * 60 - Hours * 3600
VAR Result =
    Hours & ":"
        & FORMAT ( Minutes, "00" ) & ":"
        & FORMAT ( Seconds, "00" )
RETURN
    CONVERT ( Result, DATETIME )

duration.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

Hi,

 

My end result would probably look something like this which I can then make some charts with the data.

 

Capture 1.PNG

Thanks,
David

Hi @deemon1981 ,

 

Although the type of the measure is "DateTime", you could choose the display format as "Time". This has no effect on the results.

time.jpg

 

And for "make some charts with the data", data of "Time" type can't work the same as decimal number in a chart. For example, in a bar chart:

count.jpg

 

You could choose to put [DateDiffSeconds Measure] in Values field and [Response Time in Seconds Measure] in Tooltips field.

tooltip.jpg

 

 

Best Regards,

Icey

 

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

Hi,

 

Thanks very much for getting back to me.  Sorry about my late reply, I am only getting back to this now.  This is looking great although the reponse times and durations are showing as a date in the report rather than the times.  Thoughts?

 

Many Thanks,

David

Hi @deemon1981 ,

 

take a look at this blog article:

http://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


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.