Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Email Response time from Outlook Exchange

I am trying to calculate the first response time of the emails, also I am trying to figuring out how to match received emails to sent emails,  

 this is an example data, the actual data is thousands of rows long.

Folder PathSubjectdate time sent date time received IDSender AddressReceiver Address
\Sent Item\Re:Complaint for service11/17/2020 10:5411/17/2020 10:54aamkiushjjerjerjl[email protected][email protected]
\Reeceived item \Complaint for service11/16/2020 15:5411/16/2020 15:54aamkiushjjerjerjl[email protected][email protected]
\Sent Item\Re:Complaint for service11/17/2020 11:5411/17/2020 11:54aamkiushjjerjerjl[email protected][email protected]
\Sent Item\Re:Complaint for service11/17/2020 12:5411/17/2020 12:54aamkiushjjerjerjl[email protected][email protected]
\Reeceived item \Office timings11/16/2020 15:5411/16/2020 15:54lkjjasg[email protected][email protected]
\Sent Item\Followup11/16/2020 15:5411/16/2020 15:54hjjksie[email protected][email protected]

 

1) So my question is what is how to calculate the time between when the initial email was received and when the first response was sent? 

2) Additionally, I want to count those emails as well which are not actioned or respond 

Thanks in advance for your support 

 

  • Jimmy801's avatar
    Jimmy801
    5 years ago

    Hello Anonymous 

     

    exactly, I choose the duration in minutues. 1140 minutes are 19 hours. You can change this also to hours. Just replace the Duration.TotalsMinutes to Duration.TotalHours. If you remove this function completely you will get a duration-value like 0.19:00:00

    For sure you have to remove my resource steps with your query. This is only to show how to get the result. This kind of transformation you have to dig in the M-code :). If you are not able to apply my code, you can post your query here, then I can do it for you. But be aware that my solution works with your data provided. If your data is different, it may not work and we need to adapt it even more. 


    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy 

11 Replies

  • Jimmy801's avatar
    Jimmy801
    Community Champion

    Hello Anonymous 

     

    It's possible to use the ID-Column for grouping a conversation or it's needed to group by subject?

     

    BR

     

    Jimmy

    • Anonymous's avatar
      Anonymous
      Not applicable

      Yes sure

  • Anonymous's avatar
    Anonymous
    Not applicable

    Can you help me with this? how can I do that? Thanks

    • Jimmy801's avatar
      Jimmy801
      Community Champion

      Hello Anonymous 

       

      check out this solution. Applies Table.Group and analysis the create grouped table. 2 indicators are caclulated. Duration between Received and Min Sent mail. About your second request I'm not sure. Currently is shows true if in a conversation was find a Sent Item-mail. Here the M-code

      let
          Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tZHRCoIwFIZfZXgd6aYWdBUEQVeBXWoXw451dHPi1Ojt2yooUqKiYFffgf3f+U8cO0mygbIhqwZkkjgjJ4LZQslKcDQ0UzXRUHeYghlR6tKpyzzmEerNwmAYcS4LbPUhz6G2Txhmf+TlaS45inGqpEWtbpSE+s62I2sTAaSAHewIGiVycXolNLmlh3ehJzQo1EsfkLwKfVUP7ddDf1LPVzasb8P+dqx1lhkD0qDEcq/fvpIo8pzrvR2yIAg/PsxSCaGObfV2oNm50AjDC4eB7z/kbc8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Folder Path" = _t, Subject = _t, #"date time sent " = _t, #"date time received " = _t, ID = _t, #"Sender Address" = _t, #"Receiver Address" = _t]),
          #"Changed Type" = Table.TransformColumnTypes(Source,{{"Folder Path", type text}, {"Subject", type text}, {"date time sent ", type datetime}, {"date time received ", type datetime}, {"ID", type text}, {"Sender Address", type text}, {"Receiver Address", type text}}, "en-US"),
          #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"AllRows", each _, type table [Folder Path=text, Subject=text, #"date time sent "=datetime, #"date time received "=datetime, ID=text, Sender Address=text, Receiver Address=text]}}),
          CreateResult = Table.AddColumn
          (
              #"Grouped Rows",
              "Result",
              (row)=> 
              let 
                  HasSent = if List.Count(List.Select(row[AllRows][Folder Path], each _ = "\Sent Item\"))>0 then true else false,
                  HasReceived = if List.Count(List.Select(row[AllRows][Folder Path], each _ = "\Reeceived item \"))>0 then true else false,
                  DurationIfHasSentAndHasReceived = if HasSent = true and HasReceived = true then
                      Duration.TotalMinutes(List.Min(Table.SelectRows(row[AllRows], each [Folder Path]= "\Sent Item\")[#"date time sent "]) - 
                      Table.SelectRows(row[AllRows], each [Folder Path]= "\Reeceived item \")[#"date time sent "]{0})
                      else 
                      null
              in 
                  [HasSent = HasSent, DurationReceivedAndFirstSentMail =DurationIfHasSentAndHasReceived  ]
          ),
          #"Expanded Result" = Table.ExpandRecordColumn(CreateResult, "Result", {"HasSent", "DurationReceivedAndFirstSentMail"}, {"HasSent", "DurationReceivedAndFirstSentMail"})
      in
          #"Expanded Result"

       

      Copy paste this code to the advanced editor in a new blank query to see how the solution works.

      If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
      Kudoes are nice too

      Have fun

      Jimmy

      • Anonymous's avatar
        Anonymous
        Not applicable

        Jimmy801  I really appreciate your help and for the prompt response, here I am sharing the results the duration seems to me incorrect if you see the highlighted timings the response time should be 18 hours, can you please explain or something I am not doing right   

        Thanks.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Considering I am a new user of Power BI, please tell me if I need to apply this query to real data. Are there any changes I need to make? as per your instructions after copying the same query, the system is giving me the test values.

    BR

  • Hi Jimmy801 , I hope you can answer this question. I am working with an outlook database, and to know the days elapsed since an email with a case to be resolved is received until its resolution, but I would not know how to put together the formula (I have the dates of sent and received), since there would be many mails (different cases per client) I thought of doing it by subject: when it starts, put region_customername_test1 and when region_customername_resolved_test1 is resolved. Would you have any suggestion? Is this possible to do? Thank you in advance

  • how do you even get this email data? I'm trying to do something similar, but the admin center is only showing aggregates.