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
Super User
Super User

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

@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
Super User
Super User

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

@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 Community Champion
Community Champion

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

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.

Fnu Helper I
Helper I

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

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)

 

Super User
Super User

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

@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

Fnu Helper I
Helper I

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

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! 

Super User
Super User

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

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

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

Thank you for your response! 

Fnu Helper I
Helper I

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

Hi @mdevaney 

 

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

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (9,084)