The Power Apps Find Function is used to search a substring within a larger string of text.
Here are a few scenarios on which it can be useful:
- Extracting data based on keywords (e.g. finding a specific address, descriptions, zip codes or other data)
- Validating user input (Helpful when comparing two (2) sets of text to ensure accuracy of data entered)
- Splitting or cleaning up data
- Parsing or formatting data when dealing with form submissions or data upload
- Extracting information from complex skills
For this article, we’ll only focus on implementing the basic Find Function.
Step 1
On a Canvas App, add two (2) Text Input fields by clicking Insert > Text Input.
Drag and drop the fields on each side of the screen.
Step 2
Go to Insert > Text Label, then drag and drop the text label to the bottom-center of the screen.
Your application screen should look like this once you have added the text fields and label:
Step 3
Increase the size of the text in the input fields and text label on the Properties pane to 15.
Step 4
Click the Text Label then set the alignment to Align Center.
Step 5
Add labels above the text input fields and rename them to:
- Find – This is where you will enter the text to find in the larger string.
- In – This is where you insert text where it will look for the searched string.
Step 6
Remove the text inside the text fields.
You can either do it on the fields themselves, or on the Text field of the Properties Pane.
Step 7
Remove the text in the Text Label at the bottom-center.
This is where the search response will appear on your application.
Step 8
Rename the text input fields on the Tree View to TextInputIn and TextInputFind.
Step 9
Go to Preview mode and enter a sample text string.
In this example, we entered Joey Ramone, Slash, and Lars Ulrich.
At this point, the Power Apps Find Function won’t work yet as we need to program the Find field and the text label.
Step 10
Exit the Preview mode and select the bottom-center text field.
Step 11
Program the text label so it only displays a value if both the Find and In fields have data.
Go to the formulaFX field and enter this formula:
If(IsBlank(TextInputFind.Text) Or IsBlank(TextInputIn.Text),” “,)
Step 12
To program the text label so it returns a specific value when the text in the In field contains the subtext from the Find field, add the rest of the formula.
If(IsBlank(TextInputFind.Text) Or IsBlank(TextInputIn.Text),” “, If(Find(TextInputFind.Text, TextInputIn.Text)>0, “Yes, I found it”, “Sorry, try again.”))
Step 13
Go to Preview Mode and test the application.
When the field with the larger text does not contain the subtext, it should return a value of “Sorry, try again.”
When the subtext contains any text within the larger text string, it should return the value “Yes, I found it.”
For this Find function, it is important to know that:
- It is case sensitive. Even if you entered the correct text, it will return a FALSE value if it is not in the correct case.
- When a part of any text within the larger text string is entered in the Find field, it will return a TRUE value.
Leave a Comment