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 / Gallery Filter from Ta...
Power Apps
Unanswered

Gallery Filter from TabList with If functions

(0) ShareShare
ReportReport
Posted on by 643

I have a tab list that I wish to filter the Gallery to only show items assigned to certain staff. This list also needs an all function which if selected does not sort and shows all items regardless of who is assigned.

 

jamescosten_0-1706704364454.png

I cant get the initial fx to work and I need a filter for if all is selected so i have come to the master sof PA.

Categories:
I have the same question (0)
  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @jamescosten 

     

    This one is pretty easy:

     

    If(WTRFWIPTABLIST.Selected.Value='All'),
     'WTRF Database',
     Filter('WTRF Database',WTRFWIPTABLIST.Selected.Value,'Assigned To'.DisplayName)
    )

     

     

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.

    Thanks

    -Mark

     

  • jamescosten Profile Picture
    643 on at

    Hi Mark, This desnt error but it does not work, the gallery shows all items no matter the selection.

     

    The Tab list is a manual list and not linked to Source, as I could figure out how to add an ALL Option. The names match that of the assigned to but perhaps because its manual it doesn correlate?

     

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @jamescosten ,

     

    Sorry about that. I mistyped. You need some way of know that "All" was selected. What kind of control did you use to display the "All" and the rest of the names?

     

    The code should be something like:

    If(<Insert Condition that indicates that ALL was selected>),
     'WTRF Database',
     Filter('WTRF Database',WTRFWIPTABLIST.Selected.Value,'Assigned To'.DisplayName)
    )

     

    Is "All" a button or a button in a Gallery on your form? You need a way to know that "All" is the choice and then the "IF-THEN" can be updated for your data source.

     

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.

    Thanks.

    -Mark

  • jamescosten Profile Picture
    643 on at

    Hi Mark, You had it correct before the Tablist has a list of names and the word all:

     

    ["All","Darryl","Lee","Carl"]

     

    On the gallery I have a Assigned to label which is based upon a person column in SP. So i search the name and assign. I would then like my Tablist to filter the gallery based upon the person selected, using the names in the Tablist.

     

    Unless I change my column to me a choice column and I add the people in, but how could i have an "All" option

     

  • jamescosten Profile Picture
    643 on at

    @MarkBandR I have changed the way it works, I have managed to change the tablist to pull from the choices column in the assigned to. So they both have the same source. I have added a search bar and the Gallery's items is as follows:

     

    If(!IsBlank(Searchbox_2.Text),Filter('WTRF Database',Find(Searchbox_2.Text, 'Tool Number'.Value)),Filter('WTRF Database',WTRFWIPTABLIST.Selected.Value,'Assigned To'.Value))

     

    The Tab list items is set to: Choices('WTRF Database'.'Assigned To')

     

    And the Gallery Label has ThisItem.'Assigned To'.Value.

     

    When searching it will filter the gallery but when false it will not sort by the assigned? It seems to work with a dropdown but not the New Tab control?

     

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @jamescosten 

     

    You are going to need to use a Collection.

     

    Here is a great article by @mdevaney on using Collections:

    https://powerusers.microsoft.com/t5/Community-App-Samples/Collections-Cookbook-50-Visual-Examples-amp-Code/m-p/437594

     

    Given that. You can do something like:

     

     

    ClearCollect(colPeopleTabs, {DisplayName: "All"});
    Collect(colPeopleTabs, AddColumns(Distinct('Your SPList', 'AsignedTo'.DisplayName), "DisplayName",Value));

     

     

    This will create a Collection. Set your Gallery to use the Collection created named "colPeopleTabs".

    The above code should be put in an OnSelect or a button or other control or OnVisible for the form.

     

     

  • MarkRahn Profile Picture
    1,229 Super User 2025 Season 2 on at

    Hi @jamescosten ,

     

    Based on what you provided, I built an App connected to a SharePoint List. I know you are using a database so some of your code will be different (such as using Find() instead of StartsWith() in the Filter)

     

    The main Screen has a Search box, a Modern Controls Tab List, and a Gallery:

    MarkBandR_0-1706725282172.png

    You said you currently have the "Tab List" - Items set to:

     

     

    Choices('WTRF Database'.'Assigned To')

     

     

    Is your "Assigned To" field a Choice Field or a People Picker?

     

    I am using SharePoint as my data source so the above code will not return all the available choices for a People Picker for me. If that is working for you then jump down to where I talk about setting the "Items" property without using a Collection.

     

    I think you should be using a Collection for the "Items" property of the Tab List but you don't have to.

    If you were going to use a Collection, then you would do something like:

     

     

    ClearCollect(colPeopleTabs, {DisplayName: "All"});
    Collect(colPeopleTabs, AddColumns(Distinct('WTRF Database20240131', 'Assigned To'.DisplayName), "DisplayName",Value));

     

     

     

    This is the complicated code to avoid using a Collection. You need to change it to match your data source names:

     

     

    With(
     {
     outputTable: Ungroup(
     Table(/* Create the table with child tables. If you want to join more tables, add more items to this table and the formula will work the same way*/
     {tableObject: Table({Value:"All"})},
     {tableObject: SortByColumns(ForAll(Distinct('WTRF Database20240131', 'Assigned To'.DisplayName), Value),"Value")}
     ),
     "tableObject"
     )/* Merges all the tables into a single one, but no duplicates removed */
     },
     ShowColumns( //Display only the columns needed
     GroupBy(
     outputTable,
     "Value",//add the columns to extract distinct data. any column to be used has to be added here, and in the ShowColumns piece
     "Grouped"//Last parameter can be any name as it's just the name for a child table with grouped data
     ),
    //same columns used on the GroupBy piece except the last one (the child table name)
     "Value"
     )
    )

     

     

    I pulled this together with help from this blog post:

    Power Apps: Merge tables/collections and get distinct records (without using Collect) - michelcarlo

    by @michelcarlo (Second time in two days he has had a blog post to help out)

     

     

     

    This code is for the Gallery - Items Property. It has nested If-Then's to accomplish what you are looking for. I used StartsWith() instead of Find() because that is what SharePoint supports. Since you are using a DB, you can change those to Find():

     

    If(
     !IsBlank(Searchbox_2.Text),
     If(
     WTRFWIPTABLIST.Selected.Value = "All",
     //Return items JUST SEARCHING for the Tool Number
     Filter(
     'WTRF Database20240131',
     StartsWith(
     'Tool Number',
     Searchbox_2.Text
     )
     ),
     //Return items using the search for Tool Number AND the User selected in the TAB
     Filter(
     'WTRF Database20240131',
     And(
     StartsWith(
     'Tool Number',
     Searchbox_2.Text
     ),
     'Assigned To'.DisplayName = WTRFWIPTABLIST.Selected.Value
     )
     )
     ),
     If(
     WTRFWIPTABLIST.Selected.Value = "All",
     //Return ALL items
     'WTRF Database20240131',
     //Return items using the User selecte in the TAB
     Filter(
     'WTRF Database20240131',
     'Assigned To'.DisplayName = WTRFWIPTABLIST.Selected.Value
     )
     )
    )

     

     

    Hopefully this all makes sense and helps.

     

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up.

    Thanks

    -Mark

     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard