Forum Discussion

sagivh's avatar
sagivh
Microsoft Employee
6 years ago
Solved

Aggregate text events with time difference

Hello, I am trying to aggregate events and cannot find the right method to do so.

 

I have a data similar to this, its basiclaly a list of events with either error or succcess, a timestamp and a unique user id. 

 

DateUserEvent
1-JanAfailure
1-JanCfailure
3-JanAsuccess
3-JanCfailure
4-JanBfailure
4-JanBfailure
7-JanCsuccess

 

 

I am looking for a way to be able to agregate this to something of the following:

show the final resault, if the final event is success or falure, and show the time between the failures to the final success but only if it ended with success (if all failures, no time or specific value). 

 

Userfinaldiff
ASuccess2 days
BFail 
CSuccess6 days

 

Is that possible?

 

Thanks. 

  • Hi sagivh 

    try new table

    Table = ADDCOLUMNS(summarize('Query';'Query'[User];"Lastevent";LASTNONBLANK('Query'[Event];1);"LastDate";LASTNONBLANK('Query'[Date];1));"diff";if([Lastevent]="success";DATEDIFF(FIRSTNONBLANK('Query'[Date];1);[LastDate];DAY);0))

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    LinkedIn

3 Replies

  • az38's avatar
    az38
    Community Champion

    Hi sagivh 

    try new table

    Table = ADDCOLUMNS(summarize('Query';'Query'[User];"Lastevent";LASTNONBLANK('Query'[Event];1);"LastDate";LASTNONBLANK('Query'[Date];1));"diff";if([Lastevent]="success";DATEDIFF(FIRSTNONBLANK('Query'[Date];1);[LastDate];DAY);0))

    do not hesitate to give a kudo to useful posts and mark solutions as solution

    LinkedIn

    • sagivh's avatar
      sagivh
      Microsoft Employee

      Thank you so much az38! this worked. its pretty amazing to see this kind of smart query. 

  • sagivh is there always going to be one success for each user? or there can be multiple failures and successes for each user? Measure is going to be based on that.