Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Gallery filter - multiple criteria

(0) ShareShare
ReportReport
Posted on by 119
Dear Community,
 
I have an app with data source SharePoint list called "List".
 
On the app screen I have 4 criteria, based of which the gallery should be filtered, however the filtering based on combination of multiple criteria does not work (there is no error, it just does not filter based on the selected criteria):
 
Toggle1 Show all items
Combo Box DataCardValue26 (Group) 
TextInput_City_1 City
TextInput_PostCode Postal Code
 
How it should work:
If toggle (saying "show all items") is ON, do not filter based on User e-mail. If toggle is OFF - filter only items where the current user is in column "User". Then in the next step filter based on the combination of the other criteria - city, postal code and Combo Box chosen value (Group).
 
The Items property of the gallery contains this formula. Could you please help me to correct the formula?
 
If(
    Toggle1.Value = false,
    If(
        !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode.Text <> "",
        Filter(
            Filter(
                'List',
                'User E-mail_not visible_1'.Text = 'User'.Email
            ),
            DataCardValue26.Selected.Value = 'Group'.Value && TextInput_City_1.Text = City && TextInput_PostCode.Text = 'Postal Code'
        ),
         If(
                !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode.Text = "",
                Filter(
                    Filter(
                        'List',
                        'User E-mail_not visible_1'.Text = 'User'.Email
                    ),
                 DataCardValue26.Selected.Value = 'Group'.Value && TextInput_City_1.Text = City 
                ),
            If(
                !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text = "" && TextInput_PostCode.Text <> "",
                Filter(
                    Filter(
                        'List',
                        'User E-mail_not visible_1'.Text = 'User'.Email
                    ),
                 DataCardValue26.Selected.Value = 'Group'.Value && TextInput_PostCode.Text = 'Postal Code' 
                ),
            If(
            !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text = "" && TextInput_PostCode.Text ="",
            Filter(
                Filter(
                    'List',
                    'User E-mail_not visible_1'.Text = 'User'.Email
                ),
                DataCardValue26.Selected.Value = 'Group'.Value
            ),
            If(
                IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode.Text <> "",
                Filter(
                    Filter(
                        'List',
                        'User E-mail_not visible_1'.Text = 'User'.Email
                    ),
                   TextInput_City_1.Text = City &&  TextInput_PostCode.Text = 'Postal Code'
                ),
                If(
                IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode.Text ="",
                Filter(
                    Filter(
                        'List',
                        'User E-mail_not visible_1'.Text = 'User'.Email
                    ),
                    TextInput_City_1.Text = City
                ),
            If(
                IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text = "" && TextInput_PostCode.Text <>"",
                Filter(
                    Filter(
                        'List',
                        'User E-mail_not visible_1'.Text = 'User'.Email
                    ),
                    TextInput_PostCode.Text = 'Postal Code'
                ),
            
            
           
                Filter(
                    'List',
                    'User E-mail_not visible_1'.Text = 'User'.Email
                )
            )
        )
    ))))),
    If(
        !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode.Text <> "",
        Filter(
            'List',
            DataCardValue26.Selected.Value = 'Group'.Value && TextInput_City_1.Text = City && TextInput_PostCode.Text = 'Postal Code'
        ),
        If(
            !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode = "",
                Filter(
                    'List',
                    DataCardValue26.Selected.Value = 'Group'.Value && TextInput_City_1.Text = City
                ),
        If(
                !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text = "" && TextInput_PostCode <> "",
                Filter(
                    'List',
                    DataCardValue26.Selected.Value = 'Group'.Value && TextInput_PostCode.Text = 'Postal Code'
                ),
        If(
            !IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text = "" && TextInput_PostCode.Text = "",
            Filter(
                'List',
                DataCardValue26.Selected.Value = 'Group'.Value
            ),
            If(
                IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode <> "",
                Filter(
                    'List',
                    TextInput_City_1.Text = City && TextInput_PostCode.Text = 'Postal Code'
                ),
            If(
                IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text <> "" && TextInput_PostCode = "",
                Filter(
                    'List',
                    TextInput_City_1.Text = City
                ),
            If(
                IsBlank(DataCardValue26.Selected.Value) && TextInput_City_1.Text = "" && TextInput_PostCode <> "",
                Filter(
                    'List',
                    TextInput_PostCode.Text = 'Postal Code'
                ),      
            
                'List'
            )
        )
    )
)))))
 
Thank you in advance.
  • WarrenBelz Profile Picture
    146,620 Most Valuable Professional on at
    Gallery filter - multiple criteria
    I am not getting notifications, so did not see your response.
    The code I posted is valid based on your initial post. You might take a moment to look at the logic - it will save you a lot of time in the future.
  • Eeyore2005 Profile Picture
    119 on at
    Gallery filter - multiple criteria
    Dear @WarrenBelz,
     
    I tried to shorten my code by using the one you suggested, but unfortunately I got a lot of error messages.
    However I found some mistakes in my own long code, corrected them and now all the combinations of the filtering criteria seem to work correctly.
     
    Thank you anyway and have a nice day.
  • Suggested answer
    WarrenBelz Profile Picture
    146,620 Most Valuable Professional on at
    Gallery filter - multiple criteria
    You do not need all that code for five possible filter results,
    Filter(
       'List',
       Toggle1.Value ||
       (
          'User E-mail_not visible_1'.Text = 'User'.Email &&
          (
             Len(DataCardValue26.Selected.Value) = 0 ||
             DataCardValue26.Selected.Value = 'Group'.Value
          ) &&
          (
             Len(TextInput_PostCode.Text) = 0 ||
             TextInput_PostCode.Text = 'Postal Code' 
          ) &&
          (
             Len(TextInput_City_1.Text) = 0 ||
             TextInput_City_1.Text = City 
          )
       )
    )
     
    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
  • Suggested answer
    Michael E. Gernaey Profile Picture
    40,888 Super User 2025 Season 1 on at
    Gallery filter - multiple criteria
    Hi,
     
    No way thats gonna make my eyes bleed.
     
    What you need to do, is manually take all of these Filters.
    Do them 1 by 1 to make sure that data is returned.
     
    Then add a button and in the OnSelect, add your filters 1 by 1 until it stops doing what you expect.
     
    Then you will find that a filter is bad, or they are not grouped properly by (  and )
     
    Since you have not given us data to look at, there is no way to tell you why your filters don't show the correct data. It looks fine to me but i have no idea
    what you are trying to do against what data.
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,620 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,962 Most Valuable Professional

Leaderboard