Hello. I'm trying to build a search function, and here are the input fields. The only ones that matter in this issue I'm facing now are Seat ID, Audit ID, Location, Build Event and Incomplete Audits Only (boolean).
What I'm trying to do is set up a filter so it only does filters on these input fields that have value. For example, if Seat ID and Audit ID are the only ones with value then I want to do a filter using only them. So if somebody only has Build Event filled out, then I only want to apply a filter on that field and forget the rest. So essentially, filter this entity where build event is equal to what was put into the build event combo box. All the other fields are not filtered on.
This was my attempt. I tried to store my entity in a variable and then filter than variable in sequence depending on which input fields had value.
The issue with this was my lookup fields would not longer work or display in the gallery I'm going to be applying this filter to so I decided I couldn't use a variable.
Does anyone know a way to set this up so I don't have to essentially create a ton of if statements? Thank you.
Solved! Go to Solution.
@Mgodby there are ways to filter by multiple items using only what you select/enter. Looking at the code you provided, here is an attempt to do so:
Filter(
*DataSource*,
'Seat ID' = SearchSeatID.Text,
'Audit Number' = SearchAuditID.Text,
'Build Event'.Name = SearchBuildEventComboBox.Selected.Name || SearchBuildEventComboBox.Selected.Name = Blank(),
'Build Event'.Name = SearchLocationComboBox.Selected.Name || SearchLocationComboBox.Selected.Name = Blank(),
If(
IncompleteAuditsInput.Value,
Text('Audit Status') <> "COMPLETE",
true
)
)
I'm not too certain that it will work as written, but it hopefully gives some pointers as to how to make it happen. For instance, when using combo boxes in a filter, there needs to be some way to differentiate between blank and selected items, so an or statement works well there. Also, returning the boolean value of true can be a nice trick for bypassing a section in a filter if a condition is not met.
Feel free to reply back if I can help with this further. I'd be happy to help out if needed! You also might also check out this thread, where I was having a bit of the same issue a while back.
@Mgodby there are ways to filter by multiple items using only what you select/enter. Looking at the code you provided, here is an attempt to do so:
Filter(
*DataSource*,
'Seat ID' = SearchSeatID.Text,
'Audit Number' = SearchAuditID.Text,
'Build Event'.Name = SearchBuildEventComboBox.Selected.Name || SearchBuildEventComboBox.Selected.Name = Blank(),
'Build Event'.Name = SearchLocationComboBox.Selected.Name || SearchLocationComboBox.Selected.Name = Blank(),
If(
IncompleteAuditsInput.Value,
Text('Audit Status') <> "COMPLETE",
true
)
)
I'm not too certain that it will work as written, but it hopefully gives some pointers as to how to make it happen. For instance, when using combo boxes in a filter, there needs to be some way to differentiate between blank and selected items, so an or statement works well there. Also, returning the boolean value of true can be a nice trick for bypassing a section in a filter if a condition is not met.
Feel free to reply back if I can help with this further. I'd be happy to help out if needed! You also might also check out this thread, where I was having a bit of the same issue a while back.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
190 | |
69 | |
50 | |
38 | |
28 |
User | Count |
---|---|
243 | |
114 | |
91 | |
91 | |
71 |