Creating a filter on a collection is rather simple, but how do you create a multi-level filter where a user can pick from 1-5 filter criteria and have any combination of them return the expected results? Let’s look at an example.
In this example, a user can enter any or all combinations and return a filtered sub-set from a single data set. So, if this was just a single filter, you could simply do something like this:
In this case, you would create a new collection by taking the original data set (‘Inventory Tracking’) and filter this by Supplier only if it was not equal to ‘ALL.’ This way, you can either return all results from the filter or a specific supplier.
Things are a little different if you need to create a multi-level filter. In this case, we need to create cascading collections that each filter off the prior while still being able return ‘ALL’ results for a particular filter if the user wants all suppliers, orders required, location, etc. See the below example:
Here, each collection that is created is based off the results of its predecessor. In each collection creation, the notion of allowing ‘ALL’ results is returned or filtering based off user input. Each new collection then filters the results of the previous. In the final collection created (‘collInventory6’) the product description is sorted by ‘Expiry Date.’ You simply set your Gallery Items to (‘collInventory6’) and perform the above action on the Search button click.
Some suggestions for improvement to think about based off your user requirements:
- Filter options could be cascading based off previous selections. Make the first filter enabled and all other filters disabled. Enable each subsequent filter when the previous is selected and load its options based off a previous selection.
- Take this a step further with sub-filters. Only enable/show filters if one is selected. This could still be done with the cascading collection by defaulting the sub-filter to ‘ALL’ so even if it is not visible it is always a part of the cascading collection.
- In your Gallery highlight the Search criteria the user selected to emphasize the search selection.
We hope this overview and outline of how to use multiple filters on a single data set in Power Apps was helpful! If you have further questions or want to discuss this topic in more depth, please contact us today!