Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Subtract Time Entries

Hello and thank you for taking the time to review my request.

 

I am trying figure out a way to subtract two time entries based on the following condition;

If 'Event Id' has the same value AND contains a value in the 'On Scene Separation' and 'Notified Separation', subtract the 'Notified Separation' value from the 'On Scene Separation' value.

 

For example, 'Event ID' entries 468739 and 468788 both have values in 'On Scene Separation' and 'Notified Separation' columns. For these entries, I would like to be able to subtract '4:12:00' from '4:28:00' (Event ID 468736) as well as subtract '10:07:00' from '10:20:00' (Event ID 468788). Ultimately I'd like to average those differences for a selected range using a slicer in the report.

 

Let me know if you need more explanation...sometimes it's clearer in my mind.

 

 

12 Replies

  • Anonymous , Please try as a new column

     

    new column =
    var _min = minx(filter(Table, [Event Id] = earlier([Event Id])),[Notified Separation])
    var _max = maxx(filter(Table, [Event Id] = earlier([Event Id])),[On Scene Separation])
    return
    _max - _min


    new column =
    var _min = minx(filter(Table, [Event Id] = earlier([Event Id])),[Notified Separation])
    var _max = maxx(filter(Table, [Event Id] = earlier([Event Id])),[On Scene Separation])
    return
    if( not(isblank([Notified Separation])), _max - _min , blank())

    • Anonymous's avatar
      Anonymous
      Not applicable

      I'm at a loss for where to begin with this and I don't know if what I'm asking is even possible. Here is what I'm trying to accomplish;

       

      My final result is going to be what I'm going to call Avg Response Time. This will be the difference of the OnScene time minus the Notified time for a common Event Id, Responder Id, and Responder Type. I then want to be able to average the result based on certain date ranges which I imagine can be controlled by a slicer.

       

      Here is snippet of my raw data. Using Event Id 468739 as an example, the Responder Id 5943, Responder Type Motorist Assist, yields an OnScene value of 4/1/2020 4:28 and an Notified value of 4/1/2020 4:12. The calculation will be OnScene - Notified (4/1/2020 4:28 - 4/1/2020 4:12).

       

       

      Here for 468788 the return will be Responder Id 5627, Responder Type Motorists Assist, OnScene - Notified (4/1/2020 10:20 - 4/1/2020 10:07)

       

      Thanks again for reviewing my request and let me know if you need any additional information.

       

  • Any chance you can could maybe use power query to reshape your data?  It sounds like for this specific report you might be better off having the times in different columns?

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I appreciate you taking a look at this. I'm new to coding in Power BI but I feel like this is something can be accomplished.

       

      I can narrow it down to the following...any suggestions for the next step?

       

       

      • Carmichael's avatar
        Carmichael
        Icon for Advocate III rankAdvocate III

        I am not sure why but I'm really struggling to post anything here. 

        hopefully this works....