cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fnu
Helper I
Helper I

Display items of specific field value based on buttons selected in previous screen

Hello all, 

 

I'm new to PowerApps and I need help in my app. 

 

I'm using sharepoint as the backend of my powerapp. My list has fields Title, Description, Category and Date. 

 

On the PowerApp, I have one screen that lists different categories in the form of buttons. What I'm looking for is to allow user to click on more than one buttons to select the different categories of items they want to see and then on the next screen display all the items of the categories that are selected. 

 

Any hints on how I can achieve this? 

 

I've tried using collect and patch but I keep getting an error. Not sure what I'm doing wrong. 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Fnu

I was not sure if Category was a Single Line Text column or a Choices column in SharePoint.  Try this instead.

 

Filter(your_datasource_name, Category.Value = currentCategory)

 

If you don't want the buttons to send the user to the next screen simply remove the Navigate code from each one.

Set(currentCategory, "Active");

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

8 REPLIES 8
mdevaney
Super User
Super User

@Fnu 

For this design you will require one button for each Category and a Gallery to display information from the list.  Try this example

Create a new button for each category.  Put this code in the OnSelect property.  Change the 2nd parameter to match the Category name found in your SharePoint list.

 

Set(currentCategory, "Active");
Navigate(Screen2, None);

 

Then on your 2nd screen use this code in the Items property of the gallery

 

Filter(your_datasource_name, Category = currentCategory)

 

The result will now be filtered by the category selected on the previous screen.  You can return to the previous screen by using this code in the  OnSelect property of another button or icon.

 

Back()

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

WarrenBelz
Super User
Super User

Hi @Fnu ,

I will give an example where your buttons are Red, Green and Yellow as Categories. I will call your SharePoint list MyColours and I will use a Variable called MyCat ( you can call this whatever you want). On your next screen ( I will call it ScreenCat), you have a gallery CatGallery displaying the items you want the user to see.
So on the Red Button, the OnSelect code would be

 

Set(MyCat,"Red");
Navigate(ScreenCat,ScreenTransition.Fade)

 

The green and yellow buttons would set MyCat to their value.

The Items property of CatGallery would be

 

Filter(
   MyColours,
   Category = MyCat
)

 

This will display all the items in the category set by the button.

 

Please click Accept as solution 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 Thumbs Up.

Hello mdevaney, 

 

Thank you for your response. I'm facing few issues here. When I click on any of the categories button, it takes me to the next screen which I don't want. Second, I'm getting a squiggly line under the "=" sign in the code below. When I hover over it, it says invalid argument type. 

 

Filter(your_datasource_name, Category = currentCategory)

 

@Fnu

I was not sure if Category was a Single Line Text column or a Choices column in SharePoint.  Try this instead.

 

Filter(your_datasource_name, Category.Value = currentCategory)

 

If you don't want the buttons to send the user to the next screen simply remove the Navigate code from each one.

Set(currentCategory, "Active");

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

That works! 

 

One question though, does the currentCategory hold more than one values for the categories? I have a lot of items for each category and I think the view on the second screen is restricted to show only a certain number of items for each category so I can only see the items of the last category I click on and I'm not seeing the items from others. 

Can I set a filter to display last 3 items of each category selected? 

 

Also, How can I increase the number of items showing on screen? 

 

Not sure if I should start a separate thread for these questions. Please let me know! 


Thanks your help! 

@Fnu
I would suggest posting these follow up questions in a thread as you proposed .

Thank you for your response! 

Hi @mdevaney 

 

currentCategory does not store all the categories but only the last category clicked on. 😞

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,658)