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 / Using two Filter formu...
Power Apps
Answered

Using two Filter formulas within Gallery

(0) ShareShare
ReportReport
Posted on by 467

I am looking to use both these formulas on a gallery independently or combine them so they still operate indepently.  Currently they work independently if you insert this code into the gallery items however I have yet get the gallery to accept having them both added without errors.  Basically, I want it so you are using one of the filters rather than both.  I hide the unused filter when one of them is being used with a variable.  Any help would be appreciated.

 

If(!IsBlank(ComboBox2.Selected.Result), Filter('Resource-Request', 'Service Line' = ComboBox2.Selected.Result), Sort('Resource-Request', 'Work Type', Ascending))

If(!IsBlank(ComboBox3.Selected.Result), Filter('Resource-Request', Location = ComboBox3.Selected.Result), Sort('Resource-Request', 'Work Type', Ascending))

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Hi @Dudditz ,

    Free-typed, so watch commas and brackets, but this one should allow for both to be blank also

    Sort(
     If(
     !IsBlank(ComboBox3.Selected.Result), 
     Filter(
     'Resource-Request', 
     Location = ComboBox3.Selected.Result
     ),
     !IsBlank(ComboBox2.Selected.Result), 
     Filter(
     'Resource-Request', 
     'Service Line' = ComboBox2.Selected.Result
     ),
     'Resource-Request'
     ),
     'Work Type', 
     Ascending
    )

     

    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.

  • Dudditz Profile Picture
    467 on at

    Warren you rock!  That worked perfectly.  One more question, if I wanted to use these together using the && function so they compliment each other do you have any insight on this? Thanks again for your help o this as this one has been a struggle getting the formatting right.

  • Verified answer
    WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Thanks @Dudditz ,

    When you say use together, I am assuming you want a result filtered by both if neither are blank - now it is getting complex. Again, the below was free-typed, but you should get the idea. You don't need the With() if you are happy to type in all the values repeatedly.

    With(
     {
     bLoc:!IsBlank(ComboBox3.Selected.Result),
     bSer:!IsBlank(ComboBox2.Selected.Result),
     vLoc:ComboBox3.Selected.Result,
     vSer:ComboBox2.Selected.Result
     },
     Sort(
     If(
     bLoc && !bSer, 
     Filter(
     'Resource-Request', 
     Location = vLoc
     ),
     bSer && !bLoc, 
     Filter(
     'Resource-Request', 
     'Service Line' = vSer
     ),
     bSer && bLoc,
     Filter(
     'Resource-Request', 
     'Service Line' = vSer &&
     Location = vLoc
     ),
     'Resource-Request'
     ),
     'Work Type', 
     Ascending
     )
    )

     

    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.

  • Dudditz Profile Picture
    467 on at

    Great stuff, never seen the with function used in this scenario however it worked perfect.  Going to use this in future apps.  Thanks so much for your direction on this!

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

    Thanks @Dudditz ,

    A very powerful tool - you are essentially setting (very) temporary Variables to be used further on in the code.

    Just one thing - it is a bit system resource intensive and be a little careful putting it in a large gallery when it has to calculate on every item. I think it actually broke a Power App on one my my posts a little while ago.

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 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard