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 / Convert Collection int...
Power Apps
Answered

Convert Collection into usable values for Gallery Search

(0) ShareShare
ReportReport
Posted on by 85

Hello, 

I'm having trouble with a search function, but I believe the trouble stems from the collection and so I need to figure out that issue first. I cannot figure this out. None of the forums and other online searches are yielding sucessful information. I feel like if this issue can be solved, the filter function portion will be much easier.

 

On screen one I have 4 diffent areas the user can make a choice. 2 are single choice select, 1 is mulitple choice checkboxes, and 1 is single choice checkboxes. I have a "Search" button at the bottom that will create a temporary collection based off the user's choices. The button also navigates to screen 2 where I have a gallery of products that i need to filter based on the user's selections. 

 

My button:

Miss_Zo_2-1699894345614.png

The collection:

Miss_Zo_1-1699894317092.png

The problem is the collection is a table. When I go to filter my gallery it gives an error that I cannot use table in that context to find the values in my gallery.

 

How do I convert the collection table into values that I can use to filter?

 

Thanks.

 

 

Categories:
I have the same question (0)
  • Verified answer
    Scott_Parker Profile Picture
    1,090 on at

    It appears that you just want to get the first record of your collection. Use the First() function to do so.

     

    In your case, if you don't actually want a table, would be much simpler to use Set() instead of ClearCollect(). Or you can use a context variable passed in Navigate(), instead of Set(), if you prefer.

     

    A Collection is equivalent to a table.

  • Miss_Zo Profile Picture
    85 on at

    @Scott_Parker 

    Thank you. I would prefer global variables. When I first was searching for how to do this, the concensus I was finding was you had to use a collection. 

     

    So I set global variables for each selection area. I tried to filter my gallery on screen two and I'm running into errors or there is no errors because the variable is still a table with all the selections or there are no erros and the gallery is empty and not filtering. 

     

    So I'm not sure if variables are the issue or if collection is and which is the right way to go. 

     

    I tried filtering products based off of one variable. For this variable the product must have all the selected metals listed or it should not show up.  The code doesn't have any errors besides delegation warnings (which mine is set to the max and there are not that many records), and nothing shows in my gallery.  I have a very basic selection that should populate a lot of products.

    Miss_Zo_0-1699974362940.png

     

     

     

     

  • Scott_Parker Profile Picture
    1,090 on at

    Your code looks extremely convoluted and seems to not be doing much of anything. Your outermost Filter() is either going to return all rows or no rows. Look at your two conditional statements inside of the Or(): neither of them actually references any fields present in the 'Product Family Grouping', so you're not going to be filtering anything. [Edit: I was mistaken, 'Metals Protected' is the field]

     

    Could you explain what you're trying to achieve?

     

    I will assume you want the second conditional statement to be filtering the 'Production Family Grouping' by the selections in varMetalTypes? Since you say delegation is not a problem something like the below might be suitable. I'm assuming there is a field in 'Product Family Grouping' named "MetalType"

     

     

    Filter(
     'Product Family Grouping',
     Or(
     IsEmpty(varMetalTypes),
     MetalType in varMetalTypes
     )
    )

     

     

  • Miss_Zo Profile Picture
    85 on at

    @Scott_Parker 

    What I'm trying to achieve is to be able to filter the gallery of products only if they contain all of the selected. If nothing is selected then the gallery will show all products. The metals is the hardest one which is why I started with that. 

     

    i.e.) User selects: steel, cast iron, tin 

    Product A metal_list: steel, tin, zinc

    Product B metal_list: steel, cast iron, tin, bronze, brass

    Product C metal_list: steel, bronze

     

    The gallery will only show Product B because the other two are missing one or more selections. 

    I need the rows to be filtered so that each value is matched up or not to the selected values. 

     

  • Scott_Parker Profile Picture
    1,090 on at

    Gotcha, so the requirement is that all selections must match on the product table and that is why there is a ForAll(). 

     

    I realize now 'Metals Protected' is your field from 'Production Family Grouping'. Your code looks like it should work. I'm afraid I don't have any breakthrough recommendation for you.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard