Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Filtering a Gallery - Choice -- Whats the workaround?

Posted on by 4
I have a choice selection field with Submitted Report, Report in Progress, Pending Report, Completed Report.
 
I wanted to originally create a filter in the gallery so users can filter by BOTH Report in Progress AND Pending Report's....
It appears this might be very difficult to allow the user to select multiple options from a multi-selection combo box and filter.
 
So whats the best way I can accomplish what I want to do? Is there either a workaround, or can I change my combo box to something else whilst still doing what I want?
Categories:
  • Suggested answer
    ronaldwalcott Profile Picture
    ronaldwalcott 855 on at
    Filtering a Gallery - Choice -- Whats the workaround?
    Instead of what I suggested you build a Filter statement based on the number of options in the combobox.
    The limitation of this method is that you should add a notification to the combobox indicating when the number of selected options has been reached. 
     
    Your Items becomes something like
     
    With(
        {optionCount: CountRows(ComboboxCanvas3_1.SelectedItems)},
        Switch(
            optionCount,
            0,
            'Job Descriptions',
            1,
            Filter('Job Descriptions', Department = Index(ComboboxCanvas3_1.SelectedItems, 1).Value),
            2,
            Filter('Job Descriptions', Or(Department = Index(ComboboxCanvas3_1.SelectedItems, 1).Value, Department = Index(ComboboxCanvas3_1.SelectedItems, 2).Value)),
            3,
            Filter('Job Descriptions', Or(Department = Index(ComboboxCanvas3_1.SelectedItems, 1).Value, Department = Index(ComboboxCanvas3_1.SelectedItems, 2).Value, Department = Index(ComboboxCanvas3_1.SelectedItems, 3).Value))
     
        )
    )
     
    Here I have a maximum of 3 options that can be selected. You can set the default of the switch to select all or none
  • WarrenBelz Profile Picture
    WarrenBelz 143,246 on at
    Filtering a Gallery - Choice -- Whats the workaround?
    You have not specified your data source type here,so I will post the SharePoint option (please disregard if I am incorrect). A simple filter that is not Delegable (no issue if your data numbers are under 500) - I am assuming you are filtering on your (single) choice field)
    Filter(
       SPList,
       YourFieldName.Value in ComboBoxName.SelectedItems
    )
    If you want some Delegation capability
    Ungroup(
       ForAll(
          ComboBoxName.SelectedItems As _Items,
          Filter(
             SPLiastName,
             YourFieldName.Value = _Item.Value
          )
       ),
       Value
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     
  • backinbusiness Profile Picture
    backinbusiness 4 on at
    Filtering a Gallery - Choice -- Whats the workaround?
    Unfortunately I will have large data set…3,000-5,000 rows per year. Sounds like it’s not an option then?
     
    is there a different structure instead to allow for a similar filtering outcome?
  • Suggested answer
    ronaldwalcott Profile Picture
    ronaldwalcott 855 on at
    Filtering a Gallery - Choice -- Whats the workaround?
    I have a method that I was playing with using a Job Description table and filtering by department which is a choice selection in Dataverse, I would not recommend using this for large data sets.
     
    I created a combo box, with "allow multiple selection" on, and set its Items property to 
     
    Choices('Job Descriptions'.Department)
     
     
    I then set the OnChange property of the ComboBox to 
     
    ClearCollect (
        testViewSelected,
        Filter(
            'Job Descriptions',
            Department = ComboboxCanvas3.Selected.Value
        )
    );
     
    Clear(testViewSelected);
     
    ForAll(
        ComboboxCanvas3.SelectedItems,
     
        Collect(testViewSelected, Filter(
            'Job Descriptions',
            Department = Value)
        )
    );
     
     
    The first ClearCollect is used to create the Collection format. No, it doesn't have to be in the OnChange but I was only testing the feasibility of the approach.
    The collection has to be cleared using the Clear because the collection is built by iterating the selected departments and adding to the collection.
    The Collect creates the collection by filtering for each department.
     
    I used a DataTable to display the data by setting the items to testViewSelected.
     
    I saw a bunch of weird behaviour at first where the items property of the DataTable didn't recognize the collection name until after a second or two. No data was being retrieved for the columns when I viewed the collection until I specified the columns in the DataTable. I also tested it with a gallery.
     
     
     
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard