cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

How to only filter on fields where their corresponding input fields have value?

Hello. I am trying to make a search function. Here are the fields:

 

mycriteria.png

 

The only ones that matter are Seat ID, Audit ID, Location, Build Event and Incomplete Audits Only (boolean). So what I want is to only do a filter on fields where there corresponding input fields have value. So for example, if search ID is the only input field with a value here, then I only want to filter on the Search ID field for my entity. So if Build Event and Audit ID are the only ones with value, I want to only filter on Build Event and Audit ID and forget the rest.

 

Here was my attempt:

 

myattempt.png

 

So I tried to store the entity in a variable and then do a filter in sequence on that variable depending on what input fields had value. The issue with this is I can't use the lookup fields in the gallery that uses my entity; using the variable makes it so they can't be found.

 

Is there a way to do this so I don't have to do a ton of if statements? Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: How to only filter on fields where their corresponding input fields have value?

HI @Mgodby ,

I have picked your post up from the unanswered list and will try to help you.

Before I delve into your rather complex code, I will offer an alternate path that requires a little bit of other configuration.

The code below relies on the both the text boxes and combo boxes having a default value of "" (empty String), not blank. I use it for multiple filters on text boxes and have done a small test and it works with combo boxes also containing this value. The last variable I have put on the end, although it should be fairly close to the intention.

If you want all items to display from the start, you don't need the If statement at the front.

If(
   SearchSeatId.Text<>"" || 
   SearchAuditId.Text <> "" ||
   SearchBuildEventComboBox.Selected.Name <> "" ||
   SearchLocationComboBox.Selected.Name <> "",
   Filter(
      AuditHeaderVariable,
      StartsWith(
         'Seat ID', 
         SearchSeatld.Text
      ),
      StartsWith(
         'Audit Number',
         SearchAuditld.Text
      ),
      StartsWith(
         'Build Event'.Name,
         SearchBuildEventComboBox.Selected.Name
      ),
      StartsWith(
         'Build Event'.Name, 
         SearchLocationComboBox.Selected.Name
      ),
      StartsWith(
         'Build Event'.Name, 
         SearchLocationComboBox.Selected.Name
      ),
      If(
         IncompleteAuditsInput.Value, 
         Text('Audit Status') <> "COMPLETE"
      )
   )
)
  

 

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.

View solution in original post

1 REPLY 1
Highlighted
Super User III
Super User III

Re: How to only filter on fields where their corresponding input fields have value?

HI @Mgodby ,

I have picked your post up from the unanswered list and will try to help you.

Before I delve into your rather complex code, I will offer an alternate path that requires a little bit of other configuration.

The code below relies on the both the text boxes and combo boxes having a default value of "" (empty String), not blank. I use it for multiple filters on text boxes and have done a small test and it works with combo boxes also containing this value. The last variable I have put on the end, although it should be fairly close to the intention.

If you want all items to display from the start, you don't need the If statement at the front.

If(
   SearchSeatId.Text<>"" || 
   SearchAuditId.Text <> "" ||
   SearchBuildEventComboBox.Selected.Name <> "" ||
   SearchLocationComboBox.Selected.Name <> "",
   Filter(
      AuditHeaderVariable,
      StartsWith(
         'Seat ID', 
         SearchSeatld.Text
      ),
      StartsWith(
         'Audit Number',
         SearchAuditld.Text
      ),
      StartsWith(
         'Build Event'.Name,
         SearchBuildEventComboBox.Selected.Name
      ),
      StartsWith(
         'Build Event'.Name, 
         SearchLocationComboBox.Selected.Name
      ),
      StartsWith(
         'Build Event'.Name, 
         SearchLocationComboBox.Selected.Name
      ),
      If(
         IncompleteAuditsInput.Value, 
         Text('Audit Status') <> "COMPLETE"
      )
   )
)
  

 

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.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,680)