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 / Gallery Item Filter us...
Power Apps
Unanswered

Gallery Item Filter using 2 Combo boxes + Show all Items when boxes empty

(0) ShareShare
ReportReport
Posted on by 3

Been trying to get this working for ages and could use some assistance:

 

If(

    _varSiteAdmin,

    If(

        IsBlank(drpRequestStatusFilter.SearchText),

        If(

            IsBlank(cmbRequestTypeFilter.Selected.Result),

            Sort(

                CustomerRequests,

                Created,

                Descending

            ),

            Sort(

                Filter(

                    CustomerRequests,

                    'Customer Request Type' exactin cmbRequestTypeFilter.Selected.Result

                ),

                Created,

                Descending

            )

        ),

        If(

            IsBlank(cmbRequestTypeFilter.Selected.Result),

            Sort(

                Filter(

                    CustomerRequests,

                    Status = drpRequestStatusFilter.Selected.Result

                ),

                Created,

                Descending

            ),

            Sort(

                Filter(

                    CustomerRequests,

                    Status = drpRequestStatusFilter.Selected.Result And 'Customer Request Type' exactin cmbRequestTypeFilter.Selected.Result

                ),

                Created,

                Descending

            )

        )

    ),

    /*isAdmin False/Else Value Code:*/

    If(

        IsBlank(drpRequestStatusFilter.SearchText),

        If(

            IsBlank(cmbRequestTypeFilter.Selected.Result),

            Sort(

               Filter(

                    CustomerRequests,

                    'Customer Email' exactin _varUserEmail

                ),

                Created,

                Descending

            ),

            Sort(

                Filter(

                    CustomerRequests,

                    'Customer Request Type' exactin cmbRequestTypeFilter.Selected.Result And 'Customer Email' exactin _varUserEmail

                ),

                Created,

                Descending

            )

        ),

        If(

            IsBlank(cmbRequestTypeFilter.Selected.Result),

            Sort(

                Filter(

                    CustomerRequests,

                    Status = drpRequestStatusFilter.Selected.Result And 'Customer Email' exactin _varUserEmail

                ),

                Created,

                Descending

            ),

            Sort(

                Filter(Filter(

                    CustomerRequests,

                    Status = drpRequestStatusFilter.Selected.Result And 'Customer Request Type' exactin cmbRequestTypeFilter.Selected.Result), 'Customer Email' exactin _varUserEmail

                ),

                Created,

                Descending

            )

        )

    )

)

 

The code has no errors but just doesn't seem to like the current configuration.

 

_varSiteAdmin is set OnStart by the following code:

 

If(Is blank(Lookup ('Lookup - AdminSettings','Setting Type' exactin "Site Admin" And 'Setting Value' exactin _varUserName)), Set(_varSiteAdmin,false),Set(_varSiteAdmin,true))

 

This code is fine and works for my purposes but the Items code above is what is no longer working.

 

I want to be able to use two separate combo boxes to filter results and if the boxes are empty/if you remove a selected option from combo box then I want it to show all items.

 

Thanks in anticipation

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Nayfen 

    Please consider changing your Formula to the following:

    Sort(
     Filter(CustomerRequests,
     (IsBlank(cmbRequestTypeFilter.Selected.Result) || 'Customer Request Type' in cmbRequestTypeFilter.Selected.Result) &&
     (IsBlank(drpRequestStatusFilter.Selected.Result) || Status = drpRequestStatusFilter.Selected.Result) &&
     (_varSiteAdmin && 'Customer Email' in _varUserEmail),
     Created,
     Descending
    )
    

    This should give you what you are looking for.

     

    I hope this is helpful for you. 

  • Nayfen Profile Picture
    3 on at

    Hi Randy, thanks for the quick response! So your suggesting to replace everything in the items (my first shared code) with the code you've provided?

     

    I tried doing this and it's missing a closing Parentheses. That last ) is closing off the filter not the sort.

     

    I added a closing Parentheses at the end and it shouted at me.

     

    Sort(
     Filter(CustomerRequests,
     (IsBlank(cmbRequestTypeFilter.Selected.Result) || 'Customer Request Type' in cmbRequestTypeFilter.Selected.Result) &&
     (IsBlank(drpRequestStatusFilter.Selected.Result) || Status = drpRequestStatusFilter.Selected.Result) &&
     (_varSiteAdmin && 'Customer Email' in _varUserEmail),
     Created,
     Descending
    )

    I added it after _varSiteAdmin) and that seems to have done it (no errors), but not seeing any items displayed in the gallery.

     

    Thanks

  • WarrenBelz Profile Picture
    154,918 Most Valuable Professional on at

    @Nayfen ,

    Firstly, credit @RandyHayes with this solution - you are missing another parenthesis (or have an extra one depending on how you deal with the last bit). If you indent the syntax properly, you will see it

    Sort(
     Filter(
     CustomerRequests,
     (
     IsBlank(cmbRequestTypeFilter.Selected.Result) || 
     'Customer Request Type' in cmbRequestTypeFilter.Selected.Result
     ) &&
     (
     IsBlank(drpRequestStatusFilter.Selected.Result) || 
     Status = drpRequestStatusFilter.Selected.Result
     ) &&
     _varSiteAdmin && 'Customer Email' in _varUserEmail
     ),
     Created,
     Descending
    )

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Nayfen 

    Thanks for the catch @WarrenBelz ...you know how it goes when typing formulas by hand!  I wish the forum had a formula editor 😉

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard