cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dudditz
Continued Contributor
Continued Contributor

Using two Filter formulas within Gallery

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))

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5
WarrenBelz
Super User
Super User

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
Continued Contributor
Continued Contributor

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.

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.

View solution in original post

Dudditz
Continued Contributor
Continued Contributor

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!

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.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,778)