web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter Gallery with mu...
Power Apps
Answered

Filter Gallery with multiple selection of checkboxes not working

(0) ShareShare
ReportReport
Posted on by 603

I have a powerapps gallery with SharePoint as the datasource. 

 

Currently filter functionality has 2 options (Filter by category and Filter by amount). Category is a single line of text field in datasource and Amount is a number field in datasource.

 

Search is working fine. Filter works if i select a single category, however if i select multiple categories it doesnt work. It also doesnt work if i check any amount checkboxes. 

 

I have also included below screenshot of my filter code. May i know where i am going wrong?

 

Main Gallery Items Property

If(
IsBlank(TextInput1.Text) && IsBlank(varSelection),
Items,
Len(TextInput1.Text) > 0,
Filter(
Items,
TextInput1.Text in 'Item Name' || TextInput1.Text in Description || TextInput1.Text in 'Unit Price' || TextInput1.Text in 'Item Category'
),
!IsBlank(varchecked) && IsBlank(TextInput1.Text) && IsBlank(varSelection),
Filter(
Items,
Switch(
varchecked,
"Under $50",
Amount >= 0 && Amount < 50,
"$50 - $100",
Amount >= 50 && Amount < 100,
"$100 - $200",
Amount >= 100 && Amount < 200,
"Above $200",
Amount >= 200
)
),
Filter(
Items,
'Item Category' = varSelection
)
)

 

Filter by Category Gallery - Items Property

Distinct(Filter(Items,'Item Category'),'Item Category')

 

Filter by Category Gallery - OnCheck Property

UpdateContext({varSelection:Gallery3.Selected.Value})

 

Filter by Category Gallery - OnUnCheck Property

UpdateContext({varSelection:Blank()})

 

Filter by Amount Gallery - Items Property

Distinct(Filter(Filter,Amount),Amount)

 

Filter by Amount Gallery - OnCheck Property

UpdateContext({varchecked:Gallery3_1.Selected.Value})

 

Filter by Amount Gallery - OnUnCheck Property

UpdateContext({varchecked:Blank()})

 

Iantaylor2050_0-1692187829090.png

 

Categories:
  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz , All,

     

    Can please assist me on the above? Thanks

  • WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    Hi @Iantaylor2050 ,

    Try this in the Gallery Items  = also confirm that 'Unit Price' is a Text field

    Filter(
     Items,
     (
     Len(TextInput1.Text) = 0 ||
     TextInput1.Text in 'Item Name' || 
     TextInput1.Text in Description || 
     TextInput1.Text in 'Unit Price' || 
     TextInput1.Text in 'Item Category'
     ) && 
     (
     IsBlank(varSelection) ||
     'Item Category' = varSelection
     ) &&
     (
     IsBlank(varchecked) ||
     Switch(
     varchecked,
     "Under $50",
     Amount >= 0 && Amount < 50,
     "$50 - $100",
     Amount >= 50 && Amount < 100,
     "$100 - $200",
     Amount >= 100 && Amount < 200,
     "Above $200",
     Amount >= 200
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz 

     

    Unit Price is a currency field. I tried the above code, however it doesnt work.

     

    Whenever the gallery is loaded, it doesnt show any record. Also if i check category filters, no records appear.

     

    If i check amount filter, records start appearing in the gallery, however filter doesnt work here. 

  • WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    @Iantaylor2050 ,

    The code is valid assuming there is data matching the various filter parts. I suggest you do some basic debugging first and test each of the elements separately to see if you get data, then the problem should be isolated.  So

    Filter(
     Items,
     (
     Len(TextInput1.Text) = 0 ||
     TextInput1.Text in 'Item Name' || 
     TextInput1.Text in Description || 
     TextInput1.Text in 'Item Category'
     )
    )

    assuming Description , 'Unit Price' and 'Item Category' are all Single Line of Text fields - then

    Filter(
     Items,
     (
     IsBlank(varSelection) ||
     'Item Category' = varSelection
     )
    )

    again assuming 'Item Category' is a Single Line of Text field and finally

    Filter(
     Items,
     IsBlank(varchecked) ||
     Switch(
     varchecked,
     "Under $50",
     Amount >= 0 && Amount < 50,
     "$50 - $100",
     Amount >= 50 && Amount < 100,
     "$100 - $200",
     Amount >= 100 && Amount < 200,
     "Above $200",
     Amount >= 200
     )
    )

    assuming Amount is a Numeric field

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz 

     

    I have tested separately each module. Code works fine. Now even the combined code also works fine without any issues. 

     

    However if i check multiple categories i.e. Apparels, Health the results shown are incorrect. It only filters by the last checked i.e. by Health.

     

    May i know why this happens?

  • Verified answer
    WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    @Iantaylor2050 ,

    It is because you are setting a single value for varSelection -  you can only select one Gallery item (I assume these are your checkboxes) at a time

    UpdateContext({varSelection: Gallery3.Selected.Value})

    This is going to get a little complicated  - so at Screen OnVisible

    ClearCollect(
     colSelection,
     {Value: Blank}
    )

    OnCheck of the Check Box

    Collect(
     colSelection,
     {Value: ThisItem.Value}
    )

    OnUncheck of the Check Box

    RemoveIf(
     colSelection,
     Value = ThisItem.Value
    )

    and the Filter for this part

    (
     CountRows(colSelection) = 1 ||
     'Item Category' in colSelection.Value
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz 

     

    I am trying to modify the above search to additionally include Select All Types and Select All Amount feature as per below screenshot.

     

    Iantaylor2050_0-1696301716660.png

     

    I have made below code change for the same, but it doesnt work properly. May i know where i am going wrong?

     

    Main Gallery Items Property

    Filter(
    Items,
    (
    Len(TextInputCanvas1_3.Value) = 0 ||
    TextInputCanvas1_3.Value||TextInputCanvas1.Value in 'Name' ||
    TextInputCanvas1_3.Value||TextInputCanvas1.Value in Description ||
    TextInputCanvas1_3.Value||TextInputCanvas1.Value in 'Price' ||
    TextInputCanvas1_3.Value||TextInputCanvas1.Value in 'Category'
    ) &&
    (
    (
    CountRows(colSelectionGal) = 1 ||
    'Item Category' in colSelectionGal.Value
    )
    ) &&
    (
    IsBlank(varcheckedGal) ||
    Switch(
    varcheckedGal,
    "Under $50",
    Amount >= 0 && Amount < 50,
    "$50 - $100",
    Amount >= 50 && Amount < 100,
    "$100 - $200",
    Amount >= 100 && Amount < 200,
    "Above $200",
    Amount >= 200
    )
    )
    )

     

    Filter by Types Gallery - Items Property

    Distinct(Filter(Items,'Item Category'),'Item Category')

     

    Filter by Types Gallery - OnCheck Property

    Collect(
    colSelectionGal,
    {Value: ThisItem.Value}
    )

     

    Filter by Types Gallery - OnUnCheck Property

    RemoveIf(
    colSelectionGal,
    Value = ThisItem.Value
    )

    Filter by Types Gallery - Default Property

    If(SelectAllTypesCheckbox.Value,SelectAllTypesCheckbox.Value,false)

     

    Select All (Types) checkbox - OnCheck

    Clear(colSelectionGal);
    ForAll(Gallery5.AllItems, Collect(
    colSelectionGal,
    {Value: ThisRecord.Value}
    ))

     

    Select All (Types) checkbox - OnUnCheck

    RemoveIf(
    colSelectionGal,
    Value = ThisRecord.Value
    )

     

    Filter by Amount Gallery - Items Property

    Distinct(Filter(Filter,Amount),Amount)

     

    Filter by Amount Gallery - OnCheck Property

    UpdateContext({varcheckedGal:Gallery5_1.Selected.Value})

     

    Filter by Amount Gallery - OnUnCheck Property

    UpdateContext({varcheckedGal:Blank()})

     

    Select All (Amount) checkbox - OnCheck (Code throws error)

    Clear(varcheckedGal);
    ForAll(Gallery5_1.AllItems, UpdateContext({varcheckedGal:Gallery5_1.Selected.Value}))

     

    Select All (Amount) checkbox - OnUnCheck (Code throws error)

    RemoveIf(
    colSelectionGal,
    UpdateContext({varcheckedGal:Blank()})
    )

  • WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    Hi @Iantaylor2050 ,

    I would have to build a model to start understanding all of that (which I cannot do presently), but I will give you a couple of tips - you cannot set a Variable inside a ForAll statement

    ForAll(
     Gallery5_1.AllItems, 
     UpdateContext({varcheckedGal:Gallery5_1.Selected.Value})
    )

    this one needs the actual filter criteria for the items to be removed (setting a Variable here is not what it needs)

    RemoveIf(
     colSelectionGal,
     UpdateContext({varcheckedGal:Blank()})
    )

     

  • Iantaylor2050 Profile Picture
    603 on at

    Hi @WarrenBelz 

     

    I get an error message stating UpdateContext function cannot be used within ForAll

     

    Iantaylor2050_0-1696304884645.png

     

  • WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    @Iantaylor2050 ,

    That is exactly what I said in the first comment below - you cannot set a Variable inside a ForAll statement

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard