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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dynamic Filtering by G...
Power Apps
Answered

Dynamic Filtering by Group and Creating a Collection

(1) ShareShare
ReportReport
Posted on by 10
ClearCollect(GQ1, FirstN(Shuffle(Filter(tbl_Questions, Group.Id = 1)), LookUp(gal_settings.AllItems, ID = 1).ti_amount.Text));
ClearCollect(GQ2, FirstN(Shuffle(Filter(tbl_Questions, Group.Id = 2)), LookUp(gal_settings.AllItems, ID = 2).ti_amount.Text));
ClearCollect(GQ3, FirstN(Shuffle(Filter(tbl_Questions, Group.Id = 3)), LookUp(gal_settings.AllItems, ID = 3).ti_amount.Text));
ClearCollect(GQ4, FirstN(Shuffle(Filter(tbl_Questions, Group.Id = 4)), LookUp(gal_settings.AllItems, ID = 4).ti_amount.Text));

ClearCollect(colQuestions, GQ1, GQ2, GQ3, GQ4);

I have above formula in my PowerApps but it's not dynamic. The number of Groups might increase in future.
How can I re-write this formula to make it dynamic?

There are two galleries, first one is gal_settings (filter) which has names of groups and text input where users put amount of questions they want to retrieve from certain group
and the second gallery is just shows shuffled questions from collection
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,075 Most Valuable Professional on at
     If you put the largest ID where I have YourMaxIDHere, this should work
    Clear(colQuestions);
    ForAll(
       Sequence(YourMaxIDHere),
       Collect(
          colQuestions,
          FirstN(
             Shuffle(
                Filter(
                   tbl_Questions, 
                   Group.Id = Value
                )
             ), 
             LookUp(
                gal_settings.AllItems, 
                ID = Value
             ).ti_amount.Text
          )
       )
    );
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee



     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard