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
})
)
);