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 / Possible to have varyi...
Power Apps
Unanswered

Possible to have varying number of collections?

(0) ShareShare
ReportReport
Posted on by 2

I have a gallery that is going to have variable lengths based on previous input. For example, if I select Option A the gallery will have 4 items and if I select Option B it will have 2 items. For each item in the gallery, I want to be able to search and select from a dropdown a result. So Option B will have 2 search boxes and dropdowns.

 

The search box will filter out data from a table based on what is inputted. And I want to be able to select in the dropdown for that specific item if there are multiple results.

 

However, I am having trouble setting up the gallery so that that the dropdown can have its own set of results to choose from.

17ngujason_0-1701115307872.png

As seen in the picture, I can search in the first box. When I hit the search button, I have it perform an UpdateContext to set it to a filtered out table. Using that context table, the dropdown will perform a GroupBy to show the results to select from.

 

Since I am updating the same context with each search button, all of the dropdowns will show the same results since it is performing a GroupBy on the same context table.

 

To fix this, I am thinking of having a varying number of collections that each search will filter from the original data table and update, allowing each dropdown to source from its own collection. Open to suggestions on if there is a better way of doing this. Thanks!

 

Categories:
  • Hassan_SZ_365 Profile Picture
    542 on at

    Hi @17ngujason ,

    1. Create Unique Collections: For each item in the gallery, dynamically create a unique collection. This collection will store the filtered results specific to that item's search box.

    2. Use the OnChange Property: In each search box, utilize the OnChange property to update its respective collection. This can be done using a formula like ClearCollect(CollectionName, Filter(DataSource, Criteria)), where CollectionName is dynamically generated or determined based on the item's position in the gallery.

    3. Bind Dropdowns to Collections: Bind each dropdown to its corresponding collection. This ensures that each dropdown shows results specific to its associated search box.

    4. Optimize Performance: To maintain performance, consider using delegation-friendly functions and limit the number of items processed.

    Example Code:

     

    // Assuming 'Gallery1' is your gallery control
    ForAll(
     Gallery1.AllItems,
     UpdateContext({varCollectionName: "Collection" & ThisRecord.ID});
     ClearCollect(
     LookUp(Collections, Name = varCollectionName), 
     Filter(DataSource, SearchCriteria = ThisRecord.SearchBox.Text)
     )
    )

     

    Notes:

    • Replace ThisRecord.ID with a unique identifier for each gallery item.
    • Adjust DataSource and SearchCriteria to match your data and search boxes.
    • This approach dynamically creates and updates collections for each gallery item.

    This method offers a tailored solution, ensuring that each dropdown reflects specific search results, enhancing the user experience and data accuracy in your PowerApp.

     

    Best Regards,

    Hassan Raza

  • 17ngujason Profile Picture
    2 on at

    It seems that I cannot perform an UpdateContext within a ForAll, do you have any suggestions on how I can dynamically create these Collection names?

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 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard