say I have 3 dropdown and 1 text field. I need to filter the data by these inputs.
if I do this code below, with && I get specific results, which I like, but this filters all the dropdowns regardless if they are blank/empty and does not provide good results. If I use && and populate all the inputs it works great giving me specific results. I tried || and this provides way too many results and they do not look accurate at all.
I tried doing If statements inside this code to like not search one of these if they are blank/empty, but I keep getting errors.
What is my best approach to exclude searches if those fields are empty. Should I be creating big If statements to provide the filter based on empty fields. cause that will be a very big nested if/else I would like to avoid...
SortByColumns(
Filter(
//Filter('PSI - PROJECTS', Dropdown_region.SelectedText.Value in region.Value || Dropdown_location.SelectedText.Value in location.Value || Dropdown_l1sponsor.SelectedText.Value in l1_sponsor.Value )
Filter('PSI - PROJECTS', Dropdown_location.SelectedText.Value in location.Value && Dropdown_l1sponsor.SelectedText.Value in l1_sponsor.Value && Dropdown_region.SelectedText.Value in region.Value)
,
search_title_code.Text in Title || search_title_code.Text in project_code || search_title_code.Text in acronym
),
"Title",
SortOrder.Descending
)
Correct - I use Len (length) as it covers both IsBlank() and IsEmpty() so Len(ControlOutput) = 0 means there is nothing in there and if this is true, no filter is applied.
Thanks for this. It looks to be working. So between the parenthesis creates like a ternary if stmt? If this input = 0 nothing happens, else search input in table?
Hi @gstlouis ,
I think this is what you are trying to do
SortByColumns(
Filter(
'PSI - PROJECTS',
(
Len(Dropdown_region.Selected.Value) = 0 ||
Dropdown_region.Selected.Value in region.Value
) &&
(
Len(Dropdown_location.Selected.Value) = 0 ||
Dropdown_location.Selected.Value in location.Value
) &&
(
Len(Dropdown_l1sponsor.Selected.Value) = 0 ||
Dropdown_l1sponsor.Selected.Value in l1_sponsor.Value
) &&
(
Len(search_title_code.Text) = 0 ||
search_title_code.Text in Title ||
search_title_code.Text in project_code ||
search_title_code.Text in acronym
)
),
"Title",
SortOrder.Descending
)
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.
MVP (Business Applications) Visit my blog Practical Power Apps
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional