cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hrocko
Level: Power Up

Filter on selection

Hello,

 

I have one data source called Equipment Inventory.  Equipment Inventory contains a column called Category (for some reason the reference is KRKQ for this column - not sure why).  The categories are laptops, projectors, and cases.  What I am trying to do is when I select the laptop image on the HomeScreen, I want to move to the BrowseGallery and only pull up laptops.  I want to do the same thing for projectors, and cases.

 

I've been on PowerApps for a couple days and here is the formula I have that isn't working:

 

Filter('Equipment Inventory',"Laptops" in Lower(krkq))

 

Thank you for your help!

Hailey

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft Employee

Re: Filter on selection

Interesting. I tried this with my own data and it worked. We must be using the wrong name somewhere or I must not understand the setup, or something.

 

What I would recommend, then, is just "hard coding" the Items property of BrowseGallery1 to filter the gallery to only one category. Once you have that working, it should be easy to set it up to work with the OnSelect of the image.

 

The three things you need to confirm is the name of the datasource 'Equipment Inventory', the name of the category (is it Category, krkq, or KRKQ? I'd recommend trying all three), and that the value for the category that you want is "Laptops". What I suspect was happening is that there was an error in the expression because we were using the wrong name for the category column, and that PowerApps was falling back on just showing all the items as a result. Anyway, here are some examples of what you should try setting BrowseGallery1's Items property to (see which one doesn't have errors and if it filters correctly):

 

Filter('Equipment Inventory', Category = "Laptops")
Filter('Equipment Inventory', krkq = "Laptops")
Filter('Equipment Inventory', KRKQ = "Laptops")

 Another thing you should confirm is that the cases and projectors really have a different value for their category. I doubt the mistake is there, but if everything else checks out, this would be my next guess.

- Paul C.
Software Engineer on PowerApps

View solution in original post

3 REPLIES 3
Microsoft Employee

Re: Filter on selection

Hi Hailey,

 

Try setting the OnSelect property of your laptop image to:

 

Set(CategoryFilter, "Laptops"); Navigate(BrowseGalleryScreen, ScreenTransition.Fade)

 

What this does is creates a variable called CategoryFilter and, when the laptop image is clicked, it sets the value of this variable to "Laptop". Next it navigates to the BrowseGalleryScreen (change this to the name of the screen where your BrowseGallery is).

 

So now we have a variable with the value we want to filter against. Next to filter the BrowseGallery, set the Items property of BrowseGallery to:

Filter('Equipment Inventory', Category = CategoryFilter)

What this does is takes all the items in 'Equipment Inventory' (your table) and filters it to only the ones whose Category (I think you'll technically need to change Category to krkq, as you mentioned) matches the variable we set.

 

Note: if the BrowseGallery is on the same screen as the image, just remove the navigate statement and semicolon from the OnSelect property, like so:

Set(CategoryFilter, "Laptops")

For the other images, just change the "Laptops" text to whatever it is you want to filter by.

 

Hope that helps!

- Paul C.
Software Engineer on PowerApps
hrocko
Level: Power Up

Re: Filter on selection

Thank you for the help Paul!

 

I completed the steps you outlined, but when I click the laptop image it does not filter the BrowseGallery1.  It simply lists laptops, projectors, and cases all together in the list like it did before.  Any suggestions on how I can make it filter by each category?  I tried using the Category labels of Laptops, Projectors, and Cases individually on each formula.  Also, I tried to see if I could filter on the Image name (I'm using the Image, Title, Subtitle, and Body layout) on the BrowseGallery1.  Image names are laptop, projector2, and laptop_case1.

 

Thanks for your time!

Hailey

Microsoft Employee

Re: Filter on selection

Interesting. I tried this with my own data and it worked. We must be using the wrong name somewhere or I must not understand the setup, or something.

 

What I would recommend, then, is just "hard coding" the Items property of BrowseGallery1 to filter the gallery to only one category. Once you have that working, it should be easy to set it up to work with the OnSelect of the image.

 

The three things you need to confirm is the name of the datasource 'Equipment Inventory', the name of the category (is it Category, krkq, or KRKQ? I'd recommend trying all three), and that the value for the category that you want is "Laptops". What I suspect was happening is that there was an error in the expression because we were using the wrong name for the category column, and that PowerApps was falling back on just showing all the items as a result. Anyway, here are some examples of what you should try setting BrowseGallery1's Items property to (see which one doesn't have errors and if it filters correctly):

 

Filter('Equipment Inventory', Category = "Laptops")
Filter('Equipment Inventory', krkq = "Laptops")
Filter('Equipment Inventory', KRKQ = "Laptops")

 Another thing you should confirm is that the cases and projectors really have a different value for their category. I doubt the mistake is there, but if everything else checks out, this would be my next guess.

- Paul C.
Software Engineer on PowerApps

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 403 members 6,040 guests
Please welcome our newest community members: