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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jjfr
Frequent Visitor

Power Query Custom Column to determine final status of grouped rows with different status'

Hi All,

 

I'm trying to clean some problematic data in Power Query. The data shows bookings for events, and is meant to give a final attendance status (e.g. cancelled, attended, booked...). However the data export (that we unfortunately can't change) is pulling a row for every attendance status change, rather than just giving us a single row per attendee with their final attendance status. It also does not give us a Status Change Date so I can't filter for the latest status.

 

Do you have any suggestions on how to write a nested if/switch statement that groups all matching rows (by Event ID and Attendee), and then determines a final status for that group based on criteria that I can write into M (not by a backend hierarchy). For example:

 

if any Attendance Status = Attended then Final Status = Attended else

if any Attendance Status = Cancelled then Final Status = Cancelled etc.

 

 

Below is an example of how I would like the Final Status to calculate:

 

jjfr_0-1724307899776.png

 

 

And here is the ideal output for my query:

 

jjfr_1-1724307933564.png

 

Any help you can give will be greatly appreciated. Thanks in advance!

 

1 ACCEPTED SOLUTION

@jjfr 

if you want to do this in PQ

you can try this

 

= Table.Group( Source,{"Event ID ", "Attendee"}, {"col", each if List.Contains([Attendance Status],"Attended") then "Attended" else "Cancelled"})

 

11.PNG

 

pls see the attachment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@jjfr 

pls see if this is what you want

 

Column =
var _status=maxx(FILTER('Table','Table'[Event ID]=EARLIER('Table'[Event ID])&&'Table'[Attendee]=EARLIER('Table'[Attendee])&&'Table'[Attendance Status]="Attended"),'Table'[Attendee])
return if(_status="","Cancelled","Attended")
 
11.PNG
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks so much for the suggestion @ryan_mayu. It's not working for me in Power Query, possibly because I'd incorrectly mentioned DAX not M as the code? When I try it I'm getting a 'Token EoF expected' error at the point where the variable is defined on the first line. Sorry if this is basic user error, I'm still pretty new to PBI.

@jjfr 

if you want to do this in PQ

you can try this

 

= Table.Group( Source,{"Event ID ", "Attendee"}, {"col", each if List.Contains([Attendance Status],"Attended") then "Attended" else "Cancelled"})

 

11.PNG

 

pls see the attachment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.