Hi ! I'm looking to build an app which requires for me to filters conditionnally the filters that I need.
Here is what I'm trying to do :
Filter(table, If(Sites_Filter <> "Tous", Site.Value = Sites_Filter, true) || If(Groupes_Dropdown.SelectedText.Value <> "Tous", GroupeID = Groupes_Dropdown.Selected.ID, true)
Can I use Filter() in a way that if condition is true, it uses my first argument as a Filter
If(Sites_Filter <> "All", arg to use as a Filter is true, arg to ignore if false)
If(Sites_Filter <> "Tous", Filter(Table, Site.Value = Sites_Filter), If(Groupes_Dropdown.SelectedText.Value <> "Tous", Filter(GroupeID = Groupes_Dropdown.Selected.ID), Table ) )
If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!
Check my LinkedIn!
Buy me a coffee!
Check my User Group (pt-PT)!
Last Post on Community
Yes, you can do that, although using If statement in the filter function is generally a bad practice.
Please consider changing your Formula to the following:
Filter(table, (Sites_Filter <> "Tous" || Site.Value = Sites_Filter) && (Groupes_Dropdown.Selected.Value <> "Tous" || GroupeID = Groupes_Dropdown.Selected.ID) )
Working with a simple Boolean result to the second parameter of the Filter function is preferred.
The above should give you what you are looking for.
I hope this is helpful for you.
Your solution works great, it just miss one thing, whenever the condition is false, i'll need Filter() to ignore the filter
For example with Sites_Filter <> "Tous"
If Sites_Filter == "Tous", then no Filter is applied
If Sites_Filter <> "Tous", then the Filter Site.Value = Sites_Filter is applied
I don't know if you see what I mean
That is correct in the formula.
If you look at the boolean logic in it, then it reads just as you mention.
However, you are also introducing another dropdown into the formula - doesn't that play a part of your results as well? You did not mention that in your reply - only the Sites_Filter.
You are kind of looking at it as a "do this", or "or this instead" - which doesn't really apply here.
The filter function is quite basic, what it does is evaluate every row of your datasource against the value in the second parameter of the filter function.
Every record is evaluated against the formula in the second parameter, so if the final result of that evaluation is true, then the record is included in the results. If it is false, then it is not included.
So in the formula provided, if Sites_Filter = "Tous", then that is true. Since that comparison is in an OR statement, then the rest of the formula is totally irrelevant as a true OR'ed with anything else will always be true (and thus the row included - i.e. "not filtered").
The only difference in the formula provided is that it also includes the Groupes dropdown. I am not sure how you are expecting to account for that based on your last reply.
If you could clarify how that play a part, then that would be helpful.
I'm sorry if I didn't explained myself very well
I need to check if a condition is true or false, then if it's true, pass the filter that the Filter() function need to add.
For example let's say that Sites_Filter is set to "Tous" and Groupes_Dropdown is Set to X
Since Sites_Filter is set to "Tous" Then I need Filter() to ignore that parameter, and not filter the table by this value,
Where as Groupes_Dropdown isn't set to "Tous" so I need to Filter in my table every records where groupe = X
Which is why I wanted to do conditional parameters like so :
Filter(data, If(condition_is_true, Filter_to_use, true) && ...) Here if my condition is true, then the If function returns the Filter that Filter() needs to use, if my condition is false, then it's passed true, which would be "ignored" since true is always true i guess.
Please tell me if I need to explain myself again, English is not my native language, sorry for the bad explanation
Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.
Your chance to join an engaging competition of Power Platform enthusiasts.
The Super User program for 2022 - Season 2 has kicked off!
Attend in person or online, there are incredible conferences and events happening all throughout the month of September.