web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / ForAll, GroupBy, Filte...
Power Apps
Unanswered

ForAll, GroupBy, Filter and Patch - how simple it seems...

(0) ShareShare
ReportReport
Posted on by 219

I have selected a row from a gallery of ticket requests... when selected I know the specific ticket request and the specific event fro the selected ticket request which has an ID value. So far I've been getting the counts back for all events which is inefficient. I need to filter the ticket requests (to perform group by) and the events to get the one specific row. These tables are then joined. 

It's throwing in the filter that is getting me here...

Instead of 'Ticket Request' I should do Filter('Ticket Request',ID=ThisItem.ID)
Instead of Events I should do Filter(Events,ID=ThisItem.EventId)

and...to top it off there's only one row in Events (after doing the filter) is the ForAll even needed?


With(
 {
 _counts: ForAll(
 GroupBy(
 'Ticket Request',
 "EventId",
 "GroupedItems"
 ),
 {
 EventId: EventId,
 CountApproved: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 2 /* approved */
 ),
 'Seats Requested'
 ),
 CountPending: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 1 /* pending */
 ),
 'Seats Requested'
 ),
 CountWaitlisted: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 3
 ),
 'Seats Requested'
 ),
 CountParkingPasses: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 2
 ),
 'Parking Pass Requested'
 )
 }
 )
 },
 ClearCollect(
 EventListing,
 ForAll(
 Events As _e,
 With(
 {
 _rec: LookUp(
 _counts,
 EventId = _e.ID
 ),
 _v: LookUp(
 Venues,
 ID = _e.VenueId,
 Title
 )
 },
 Patch(
 _e,
 {
 VenueName: _v,
 ApprovedCount: _rec.CountApproved,
 PendingCount: _rec.CountPending,
 WaitlistCount: _rec.CountWaitlisted,
 ParkingPassCount: _rec.CountParkingPasses,
 AvailableCount: _e.'Seat Capacity' - _rec.CountApproved,
 ParkingPassesAvailable: _e.'Parking Pass Capacity' - _rec.CountParkingPasses
 }
 )
 )
 )
 )
);


ClearCollect(QueueEvent,Filter(EventListing,ID=selectedEventID));

 My best guess was this.... but I'm getting errors on ... incompatibilty and the whole patch section...

With(
 { 
 _counts: ForAll(
 GroupBy(
 Filter('Ticket Request',ID=ThisItem.ID),
 "EventId",
 "GroupedItems"
 ),
 {
 EventId: EventId,
 CountApproved: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 2 /* approved */
 ),
 'Seats Requested'
 ),
 CountPending: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 1 /* pending */
 ),
 'Seats Requested'
 ),
 CountWaitlisted: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 3
 ),
 'Seats Requested'
 ),
 CountParkingPasses: Sum(
 Filter(
 GroupedItems,
 TicketStatusId = 2
 ),
 'Parking Pass Requested'
 )
 }
 ),
 _thisEvent: Filter(Events,ID=ThisItem.EventId)
 },
 
 With({
 _rec: LookUp(
 _counts,
 EventId = _thisEvent.ID
 ),
 _v: LookUp(
 Venues,
 ID = _thisEvent.VenueId,
 Title
 )
 },
 Patch(_thisEvent,
 { VenueName: _v,
 ApprovedCount: _rec.CountApproved,
 PendingCount: _rec.CountPending,
 WaitlistCount: _rec.CountWaitlisted,
 ParkingPassCount: _rec.CountParkingPasses,
 AvailableCount: _thisEvent.'Seat Capacity' - _rec.CountApproved,
 ParkingPassesAvailable: _thisEvent.'Parking Pass Capacity' - _rec.CountParkingPasses
 })
 ) 
);

 

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard