Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

help with filters and empty fields

(0) ShareShare
ReportReport
Posted on by

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
)
Categories:
  • WarrenBelz Profile Picture
    146,524 Most Valuable Professional on at
    Re: help with filters and empty fields

    @gstlouis ,

    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.

  • gstlouis Profile Picture
    on at
    Re: help with filters and empty fields

    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?

  • Verified answer
    WarrenBelz Profile Picture
    146,524 Most Valuable Professional on at
    Re: help with filters and empty fields

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard