cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Filtering with multiple criteria & fields...

Ok Pros, here's another one for you.  I have the following code and a screenshot of the screen....

 

Filter(Filter(colCombined,

If(Toggle1.Value,true,'Unit Class'.Value in colClass.Value),
If(Toggle1_1.Value,true,'Unit Class'.Value in colClass.Value),
If(Toggle1_2.Value,true, 'Unit Class'.Value in colClass.Value),
If(Toggle1_3.Value,true, 'Unit Class'.Value in colClass.Value),
If(Toggle1_4.Value,true, 'Unit Class'.Value in colClass.Value)),
StartsWith(Title,SearchBar.Text),StartsWith(LOCATION,Dropdown2.Selected.Value))

 

dpayne1022_2-1614096310637.png

 

 

 

dpayne1022_1-1614096145340.png

 

I'm going cross eyed trying to get my code to allow everything above AND if the user wants to do a keyword Search() in the SearchBar on top of everything.  So far, as close as I've gotten is dropping an If() function in the mix but that only yields one aspect I'm looking for.  

Please and thanks team!

4 REPLIES 4
Super User II
Super User II

Hi @dpayne1022 

Without knowing if your formula works, since toggles are either true or false, you can drop the most of the If's and all  .Value.  Your formula distills to:

 

With({UCVincCV:'Unit Class'.Value in colClass.Value},
 Filter(colCombined,
                 IF(
                    Toggle1,UCVincCV,
                    Toggle1_2, UCVincCV,
                    Toggle1_3,UCVincCV,
                    Toggle1_4, UCVincCV,
                    Or(IsBlank(
                               SearchBar.Text
                       ), StartsWith(
                                     Title,SearchBar.Text
                          ), StartsWith(
                                         LOCATION, Dropdown2.Selected.Value
                             )
                    )
                  )
 )
)

 

 

Thank you for that. Much cleaner.  Also, can you break that down a bit. I'm not familiar with the syntax and format of With().   What variable is UCVincCV or are you declaring it at that instance? 

Super User II
Super User II

@dpayne1022 

With() creates a very temporary variable available only within that formula. The variable can be an expression,a single value, a record or even a table and it has syntax like UpdateContext({...}). It has very minimal delay as well in execution. It wraps around the entire formula that it is used in. For a more detailed explanation and some examples see https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-with 

Thanks for responding Drrickryp! Any advice and help from you guys is excellent.  I did find out what was causing the issue.  I was using StartsWith() and I did not realize I could use the "in" operator so plainly (after I viewed the long list on ms.docs).  This yielded exactly what I was looking for.  

Thanks again!

 


Filter
(colCombined,

If(Toggle1.Value,true,'Unit Class'.Value in colClass.Value,
Toggle1_1.Value,true,'Unit Class'.Value in colClass.Value,
Toggle1_2.Value,true, 'Unit Class'.Value in colClass.Value,
Toggle1_3.Value,true, 'Unit Class'.Value in colClass.Value,
Toggle1_4.Value,true, 'Unit Class'.Value in colClass.Value),
SearchBar.Text in Title,
StartsWith(LOCATION,Dropdown2.Selected.Value))

 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (67,598)