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 / Can this be combined i...
Power Apps
Answered

Can this be combined into one statement...

(0) ShareShare
ReportReport
Posted on by 219

it works but I'm wondering if it can be combined into one statement...
In this case 'Seat Capacity' already exists in Events
But I need to calculated the available seats AFTER adding the ApprovedCount.
````

Set(
EventListingWithCounts,
ForAll(
Events As _e,
Patch(
_e,
With(
{
_rec: LookUp(
TicketRequestCounts,
EventId = _e.ID
)
},
{
ApprovedCount: _rec.CountApproved,
PendingCount: _rec.CountPending,
WaitlistCount: _rec.CountWaitlisted
}
)
)
)
);
ClearCollect(xxxx,AddColumns(EventListingWithCounts,"AvailableCount",'Seat Capacity'-ApprovedCount))


````
Do you really think that combining it into one statement is more beneficial overall?

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,275 Most Valuable Professional on at

    Hi @sasrsc1966 ,

    Not quite one statement - see the below, but I do not know where you are getting 'Seat Capacity' from.

    Clear(xxxx);
    ForAll(
     Events As _e,
     With(
     {
     _rec: 
     LookUp(
     TicketRequestCounts,
     EventId = _e.ID
     )
     },
     Collect(
     xxxx,
     {
     ApprovedCount: _rec.CountApproved,
     PendingCount: _rec.CountPending,
     WaitlistCount: _rec.CountWaitlisted
     AvailableCount:'Seat Capacity' - _rec.CountApproved
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • sasrsc1966 Profile Picture
    219 on at

    Seat Capacity comes from the existing Events table (which is the master table).
    The grouped by items are providing totals for various things from the TicketRequestsCount table.
    I'm joining them with this for all patch stmt.
    In your example will it read the value of the 'Seat Capacity' from the Events table? Hmmm?

  • Verified answer
    WarrenBelz Profile Picture
    156,275 Most Valuable Professional on at

    Hi @sasrsc1966 ,

    That is why I asked - you had not referred to this item in relation to the With() statement I cannot see your model or data, but try this

    Clear(xxxx);
    ForAll(
     Events As _e,
     With(
     {
     _rec: 
     LookUp(
     TicketRequestCounts,
     EventId = _e.ID
     )
     },
     Collect(
     xxxx,
     {
     ApprovedCount: _rec.CountApproved,
     PendingCount: _rec.CountPending,
     WaitlistCount: _rec.CountWaitlisted
     AvailableCount:_e.'Seat Capacity' - _rec.CountApproved
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

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 421 Most Valuable Professional

#2
11manish Profile Picture

11manish 153 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 116 Super User 2026 Season 2

Last 30 days Overall leaderboard