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))
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!
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?
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))
User | Count |
---|---|
197 | |
124 | |
86 | |
49 | |
42 |
User | Count |
---|---|
284 | |
159 | |
136 | |
75 | |
72 |