PowerApps Search Function: Multiple AND/OR Conditions Workaround
Searching in PowerApps is essential, especially when dealing with vast data sources. The default powerapps search function offers a powerful partial match capability for single terms across multiple fields. However, what if you need to use logical AND/OR conditions? This guide walks you through a workaround, enabling you to harness the full potential of the PowerApps search.
Understanding the PowerApps Search Function
Particularly effective against Dataverse and SQL Server data sources, the search function’s primary goal is to perform partial matches across various fields based on one search term. Unfortunately, it lacks the functionality to integrate multiple search terms with ‘and’ or ‘or’ conditions.
Using a Single Search Term across Multiple Fields
As an example, consider a list of properties. To search for records with the partial text “east” in the fields “address1” and “city”, we’d use the following syntax:
Search(Property, "east", "Address1" "City" )
Results will display records where “east” appears in either the Address1 or City fields.
The limitation arises when we wish to expand our search. Let’s say we want to find records with “east” in the “address1” or “city” fields, OR “uda” in the “country” fields. Given the search function’s constraints, achieving this is challenging.
Workaround: Searching Multiple Terms across Various Fields
To circumvent this limitation, we’d utilize the filter function coupled with the ‘in’ operator instead of using Search. This allows for the integration of additional search terms with the ‘or’ (||) operator:
Filter( Property, ( "east" in Address1 || "east" in City ) || "uda" in Country )
To achieve a logical ‘and’ condition across multiple search terms, replace the ‘||’ with ‘&&’.
While the default powerapps search function doesn’t inherently support multiple search terms across varied fields, this limitation is easily overcome. By leveraging the filter/in combination, you can enhance your PowerApps search functionality. Should you encounter any difficulties or require technical assistance with PowerApps or any other topic, contact us. Our team is ready to assist and provide solutions tailored to your needs.