Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sagivh
Microsoft Employee
Microsoft Employee

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. 

1 ACCEPTED SOLUTION
az38
Community Champion
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


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

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

az38
Community Champion
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


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
sagivh
Microsoft Employee
Microsoft Employee

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.