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 Apps
Unanswered

FirstN problem

(0) ShareShare
ReportReport
Posted on by 2

In my PowerApp, I have 2 collections: 

1. ClearCollect(colWaitlists, SortByColumns(Filter(colTESTDATA, BatchCode in colRejected.BatchCode, NominationStatus = "Waitlisted"), "field_2", "Created")) --  here, I get all the Waitlisted status participants in colTESTDATA in an ascending order (based on the registration date) 

 

2. ClearCollect(CountPerBatch, AddColumns(GroupBy(colRejected, "field_2", "Grouped"), "Count", CountRows(Grouped)) -- here, I count the # of Rejected participants in colRejected

Now I want to create a 3rd collection, where it would only get the number of waitlisted participants from colWaitlists based on how many are there rejected in a batch (CountPerBatch collection). For example, there are 5 waitlists on Batch 1 and since there are 3 rejected participants from the same batch. I want to get the first 3 waitlists and put them in my 3rd collection. 

 

I have my formula for my 3rd collection as 

 

ClearCollect(colRecords, FirstN(colWaitlists, LookUp(CountPerBatch, field_2 = ThisItem.BatchCode).Count))
**field_2 is for the BatchCode

However, it only collects the number of waitlists from the first batch (in an instance, I reject multiple participants from different batches). 

Please help. 

kneelg1_0-1710524004602.png


example:

Here's my colWaitlists, it contains 4 records (wherein 3 participants have the same batch [14] and the other is on batch 15)

kneelg1_1-1710524118205.png


There are two rejections in Batch 14 and 1 in batch 15, hence two records and one record were captured on its Count respectively (CountPerBatch collection)

kneelg1_2-1710524195553.png


However, on my 3rd collection (colRecords)--only 2 waitlisted from Batch 14 was captured, it should retrieve one waitlisted from Batch 15

kneelg1_3-1710524284296.png

 

Categories:
  • BhaskarDhone Profile Picture
    1,398 Super User 2026 Season 1 on at

    If I understand correctly, try this.

     

    ClearCollect(
     colRecords,
     FirstN(
     Filter(
     colWaitlists,
     BatchCode in CountPerBatch.BatchCode && field_2 = ThisItem.BatchCode
     ),
     LookUp(CountPerBatch, field_2 = ThisItem.BatchCode).Count
     )
    )
  • kneelg1 Profile Picture
    2 on at

    Thanks, Bhaskar. But I am still getting the same error 😞 In this instance, there are 2 rejections in Batch 14 and one in Batch 15. I should be able to get two waitlists and one in 15 to my 3rd collection. 

    kneelg1_0-1710553541805.png

    Screenshot of the number of waitlists (total 4: 3 from 14 and 1 from 15)

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard