<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to calculate 'service response time' per conversation id in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483677#M68116</link>
    <description>&lt;P&gt;Awesome, I was trying to find a solution but I'm stuck. It's a tough one for me&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 14:56:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-04-28T14:56:32Z</dc:date>
    <item>
      <title>How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2477803#M67713</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to calculate the average 'service response time' per conversation id &lt;STRONG&gt;as a measure&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 'service response time' is calculated by the difference between the 'created_at' variable from Y and X in minutes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;X&lt;/STRONG&gt; = the first row where owner_type = "User" and is_interaction = 1.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Y&lt;/STRONG&gt; = the first &lt;STRONG&gt;row after X&lt;/STRONG&gt; where owner_type = "Agent" and owner_id &amp;lt;&amp;gt; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;owner_type&lt;/TD&gt;&lt;TD&gt;owner_id&lt;/TD&gt;&lt;TD&gt;conversation_id&lt;/TD&gt;&lt;TD&gt;message&lt;/TD&gt;&lt;TD&gt;created_at&lt;/TD&gt;&lt;TD&gt;is_interaction&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;260943&lt;/TD&gt;&lt;TD&gt;Agent&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;26276&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;2022-03-01 15:00:14&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;265544&lt;/TD&gt;&lt;TD&gt;Agent&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;26276&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;2022-03-05 12:01:35&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;266749&lt;/TD&gt;&lt;TD&gt;User&lt;/TD&gt;&lt;TD&gt;153263&lt;/TD&gt;&lt;TD&gt;26276&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;2022-03-05 15:49:12&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;266750&lt;/TD&gt;&lt;TD&gt;User&lt;/TD&gt;&lt;TD&gt;153263&lt;/TD&gt;&lt;TD&gt;26276&lt;/TD&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;2022-03-05 15:49:22&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;266753&lt;/TD&gt;&lt;TD&gt;Agent&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&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&lt;TD&gt;2022-03-09 13:01:22&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;271727&lt;/TD&gt;&lt;TD&gt;Agent&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;26276&lt;/TD&gt;&lt;TD&gt;k&lt;/TD&gt;&lt;TD&gt;2022-03-09 13:01:23&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;272085&lt;/TD&gt;&lt;TD&gt;Agent&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;26276&lt;/TD&gt;&lt;TD&gt;l&lt;/TD&gt;&lt;TD&gt;2022-03-10 12:01:26&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how to calculate this?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 12:41:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2477803#M67713</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-26T12:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2482003#M67986</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Here is a sample file with the solution&amp;nbsp;&lt;A href="https://www.dropbox.com/t/eefOsChPez2kmESO" target="_blank"&gt;https://www.dropbox.com/t/eefOsChPez2kmESO&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Based on your description and the provided sample data, the time of both message "c" &amp;amp; message "d" will be subtracted from the time of message "e".&lt;/P&gt;&lt;P&gt;Similarly&amp;nbsp;the time of both message "i" &amp;amp; message "j" will be subtracted from the time of message "k".&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Average service response time (minutes) = 
AVERAGEX ( 
    VALUES ('Service  Data'[id] ),
    CALCULATE ( 
        IF ( 
            MAX ( 'Service  Data'[owner_type] ) = "User",
            VAR X = MAX ( 'Service  Data'[created_at] )
            VAR FilteredTable = 
                FILTER ( 
                    CALCULATETABLE ( 
                        'Service  Data', 
                        ALLEXCEPT ( 'Service  Data', 'Service  Data'[conversation_id] ) 
                    ), 
                    'Service  Data'[created_at] &amp;gt; X &amp;amp;&amp;amp; 'Service  Data'[owner_type] = "Agent" &amp;amp;&amp;amp; 'Service  Data'[owner_id] &amp;lt;&amp;gt; 1
                )
            VAR Y = MINX ( FilteredTable, 'Service  Data'[created_at] )
            VAR TimeDuration = DATEDIFF ( X, Y, SECOND )
            VAR Result = DIVIDE ( TimeDuration, 60 )
            RETURN
                Result
        )
    )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;Total service response time (minutes) = 
SUMX ( 
    VALUES ('Service  Data'[id] ),
    CALCULATE ( 
        IF ( 
            MAX ( 'Service  Data'[owner_type] ) = "User",
            VAR X = MAX ( 'Service  Data'[created_at] )
            VAR FilteredTable = 
                FILTER ( 
                    CALCULATETABLE ( 
                        'Service  Data', 
                        ALLEXCEPT ( 'Service  Data', 'Service  Data'[conversation_id] ) 
                    ), 
                    'Service  Data'[created_at] &amp;gt; X &amp;amp;&amp;amp; 'Service  Data'[owner_type] = "Agent" &amp;amp;&amp;amp; 'Service  Data'[owner_id] &amp;lt;&amp;gt; 1
                )
            VAR Y = MINX ( FilteredTable, 'Service  Data'[created_at] )
            VAR TimeDuration = DATEDIFF ( X, Y, SECOND )
            VAR Result = DIVIDE ( TimeDuration, 60 )
            RETURN
                Result
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 04:14:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2482003#M67986</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-28T04:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2482850#M68037</link>
      <description>&lt;P&gt;Hey &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for helping me out! Getting really close now... I only want the calculate the 'service response time' of the latest row where owner_type = "User".&lt;BR /&gt;&lt;BR /&gt;So the rows with 'id' 266749 and 271725 must be blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how to fix this? I think I should add an index column combined with the earlier function for this, but I would like to hear your approach &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 10:05:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2482850#M68037</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-28T10:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2482893#M68042</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yea can be done without index column but not today &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;&lt;P&gt;will get back to you tomorrow&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 10:20:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2482893#M68042</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-28T10:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483677#M68116</link>
      <description>&lt;P&gt;Awesome, I was trying to find a solution but I'm stuck. It's a tough one for me&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:56:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483677#M68116</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-28T14:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483678#M68117</link>
      <description>&lt;P&gt;Awesome, I was trying to find a solution but I'm stuck. It's a tough one for me&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:56:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483678#M68117</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-28T14:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483790#M68123</link>
      <description>&lt;P&gt;It is indeed&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 15:39:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2483790#M68123</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-28T15:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2484693#M68165</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the sample file with the solution&amp;nbsp;&lt;A href="https://www.dropbox.com/t/nRZI3zMA3aT7srRG" target="_blank"&gt;https://www.dropbox.com/t/nRZI3zMA3aT7srRG&lt;/A&gt;&lt;BR /&gt;Following your latest clarification, aggregation by date (for example latest time per date) shall be required as part of the calculation. In order to achieve this without further complications in the code, a date column must be added.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Date = 
DATE ( 
    YEAR ( 'Service  Data'[created_at] ), 
    MONTH ( 'Service  Data'[created_at] ), 
    DAY ( 'Service  Data'[created_at] ) 
)&lt;/LI-CODE&gt;&lt;P&gt;Then our master measure would be&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Response Time (minutes) = 
VAR CurrentDateTime =
    MAX ( 'Service  Data'[created_at] )
VAR CurrentDate =
    MAX ( 'Service  Data'[Date] )
VAR CurrentType =
    MAX ( 'Service  Data'[owner_type] )
VAR CurrentConversationTable =
    CALCULATETABLE (
        'Service  Data',
        ALLEXCEPT ( 'Service  Data', 'Service  Data'[conversation_id] )
    )
VAR CurrentDateTypeTable =
    FILTER (
        CurrentConversationTable,
        'Service  Data'[Date] = CurrentDate
            &amp;amp;&amp;amp; 'Service  Data'[owner_type] = CurrentType
    )
VAR NextTime_DateTypeTable =
    FILTER ( CurrentDateTypeTable, 'Service  Data'[created_at] &amp;gt; CurrentDateTime )
VAR NextTime_AgentTable =
    FILTER (
        CurrentConversationTable,
        'Service  Data'[created_at] &amp;gt; CurrentDateTime
            &amp;amp;&amp;amp; 'Service  Data'[owner_type] = "Agent"
            &amp;amp;&amp;amp; 'Service  Data'[owner_id] &amp;lt;&amp;gt; 1
    )
VAR X = CurrentDateTime
VAR Y =
    MINX ( NextTime_AgentTable, 'Service  Data'[created_at] )
VAR TimeDuration =
    DATEDIFF ( X, Y, SECOND )
VAR Result =
    DIVIDE ( TimeDuration, 60 )
RETURN
    IF (
        CurrentType = "User",
        IF ( ISBLANK ( COUNTROWS ( NextTime_DateTypeTable ) ), Result )
    )&lt;/LI-CODE&gt;&lt;P&gt;Then depending on average of sum:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Total Response Time (minutes) = 
SUMX (
    VALUES ( 'Service  Data'[id] ),
    [Response Time (minutes)]
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;Average Response Time (minutes) = 
AVERAGEX (
    VALUES ( 'Service  Data'[id] ),
    [Response Time (minutes)]
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 04:25:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2484693#M68165</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-29T04:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2485215#M68195</link>
      <description>&lt;P&gt;True champ!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I aggregated the date with a 5 minutes timestamp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the solution! Many thanks for the effort!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;DATE = DATEVALUE ( 'Service Data'[created_at] )
    + TIME ( HOUR ( 'Service Data'[created_at] ), MINUTE ( 'Service Data'[created_at] )
        - MOD (
            MINUTE ( 'Service Data'[created_at] ),
            5
        ), 0 )&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 08:23:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2485215#M68195</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-29T08:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 'service response time' per conversation id</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2485450#M68213</link>
      <description>&lt;P&gt;Good job &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 09:43:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-service-response-time-per-conversation-id/m-p/2485450#M68213</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-29T09:43:02Z</dc:date>
    </item>
  </channel>
</rss>

