When working with Power Apps applications, we can use the StartsWith and EndsWith functions to determine whether a text value starts or ends with a specific substring.
In this tutorial, we will learn about Power Apps StartsWith and EndsWith functions and their syntaxes in Power Apps. Also, I will explore the topics below:
- Power Apps StartsWith Example
- Power Apps EndsWith Example
- Power Apps StartsWith Delegation
- Power Apps StartsWith Multiple
- Power Apps StartsWith Number
- Power Apps SortByColumns Filter StartsWith
- Power Apps StartsWith Blank
- Power Apps StartsWith Contains
- Power Apps StartsWith Filter
- PowerApps StartsWith Wildcard
StartsWith Power Apps
- Power Apps StartsWith function helps to test whether a text string begins with another. It returns a Boolean value of true or false.
- You can use the StartsWith function with the Filter function to search the data within your app.
- You can also use the in operator or Search function within the text strings. If one of these functions can’t be delegated, you may face delegation issues.
Power Apps SrartsWith Syntax:
StartsWith( Text, StartText )
Where,
- Text = This is Required. Specify the text to test
- StartText = This is also Required. Enter the text to search for at the beginning of the Text. If StartText is an empty string, then the StartsWith returns the boolean value as true
Power Apps StartsWith Example
I have a SharePoint Online list named “Vacation Budget” and this list contains the below fields.
Column Name | Data Type |
Destination | It is a default single line of text |
Expense Name | A single line of text |
Category | Choice |
Estimated Cost | Number |
Start Date | Date and time |
End Date | Date and time |
In Power Apps, there is a Text input control and a Gallery control. Whenever the user searches for any destination, the gallery displays SharePoint list records based on the search results using the StartsWith function.
Output:
To do so, follow the below-mentioned steps. Such as:
1. On the Power Apps Screen, insert a Text input control and make its Value property blank(“”), as shown below.
2. Next, insert a Gallery control and set its Items property to the code below.
Items = Filter(
'Vacation Budget',
StartsWith(
Text(Title),
txt_Search.Value
)
)
Where,
- ‘Vacation Budget’ = SharePoint Online list
- Title = SharePoint text property
- txt_Search = Power Apps text input control name
3. Once your app is ready, Save, Publish, and Preview the app. Once the user searches for any destination from the text input control, the result will be displayed on the gallery control.
Power Apps EndsWith
- Power Apps EndsWith function helps test whether a text string ends with another. This function returns a Boolean value of true or false.
- You can also use the EndsWith function with the Filter function to search the data within your app.
- You can also use the in operator or Search function within the text strings. If one of these functions can’t be delegated, you may face delegation issues.
Power Apps EndsWith Syntax:
EndsWith( Text, EndText )
Where,
- Text = This is Required. Specify the text to test
- EndText = This is also Required. Enter the text to search for at the end of the Text. If EndText is an empty string, then the EndsWith value returns as true
Power Apps EndsWith Example
In the same way, if you want to filter and display the SharePoint list records based on the text input search results using the EndsWith function.
To do so, select the Gallery control and set its Items property to the code below.
Items = Filter(
'Vacation Budget',
EndsWith(
Text(Title),
txt_Destination.Value
)
)
Finally, Preview the app. Once the user searches for any destination from the text input control, the result will be displayed on the gallery control.
Output:
Power Apps StartsWith Delegation
When you are using the Text() function to get the SharePoint text field value, you will get the Delegation warning [The “Text” part of this formula might not work correctly on large data sets], as shown below.
To resolve this issue, you can create the Power Apps collection using the SharePoint list. In this case, select the App object and set its OnStart property as:
OnStart = ClearCollect(
colVacations,
'Vacation Budget'
)
Where,
- colVacations = Power Apps collection name
- ‘Vacation Budget’ = SharePoint Online list
Now, select the Gallery control and set its Items property as:
Items = Filter(
colVacations,
StartsWith(
Text(Title),
txt_Search.Value
)
)
This way, you can resolve the delegation warning of Power Apps StarsWith or EndsWith function.
Power Apps StartsWith Multiple
Suppose you want to work with the Power Apps StartsWith multiple; follow the simple example below.
Example:
In Power Apps, there are two text input controls for searching the Destination and Expense Name and a gallery for displaying the filter records based on the search results.
Now, select the gallery control and set its Items property as:
Items = Search(
Filter(
colVacations,
StartsWith(
Title,
txt_Destination.Value
)
),
txt_ExpenseName.Value,
Title,
'Expense Name'
)
Where,
- txt_Destination, txt_ExpenseName = Power Apps text input control names
- Title, ‘Expense Name’ = SharePoint list fields
Once your updates are done, Preview the app. When the user searches the Destination and Expense name from text input controls, the gallery displays the result, as shown below.
Output:
This is how we can work with the Power Apps StartsWith multiple.
Power Apps StartsWith Number
In this example, I will show how to work with the Power Apps StartsWith number. To do so, select the Gallery control and set its Items property as:
Items = Filter(
colVacations,
StartsWith(
Text('Estimated Cost'),
'txt_Est cost'.Value
)
)
Where,
- ‘Estimated Cost’ = SharePoint list number field
- ‘txt_Est cost’ = Power Apps text input control
Now, Preview the app. The gallery displays filtered records based on the text input search results [Estimated Cost], as in the screenshot below.
Power Apps SortByColumns Filter StartsWith
Here, I will show you how to work with the Power Apps SortByColumns filter StartsWith. To achieve it, select the gallery control and set its Items property as:
Items = SortByColumns(
Filter(
colVacations,
!IsBlank(txt_Destination.Value) && StartsWith(
Title,
txt_Destination.Value
)
),
"ID",
If(
SortOrder.Ascending,
SortOrder.Ascending,
SortOrder.Descending
)
)
Where,
- txt_Destination = Power Apps text input control name
- “ID” = SharePoint ID column
Whenever the user searches for any destination from the text input control, the gallery sorts and filters the SharePoint list records, as shown below.
This way, we can work with the Power Apps SortByColumns Filter StartsWith.
Power Apps StartsWith Blank
Suppose you want to display all the records on the gallery control when the text input control is blank. In this case, you can use the below code for the Gallery control’s Items property.
Items = SortByColumns(
Filter(
colVacations,
IsBlank(txt_Destination.Value) && StartsWith(
Title,
txt_Destination.Value
)
),
"ID",
If(
SortOrder.Ascending,
SortOrder.Ascending,
SortOrder.Descending
)
)
Now, Preview the app. If the text input control is blank, the gallery displays all the SharePoint list records, as shown below.
Power Apps StartsWith Contains
In this section, I will explain how to work with the Power Apps StartWith Contains. To work around this, select the gallery control and set its Items property as:
Items = Search(
colVacations,
txt_Destination.Value,
Title
)
Now, search for any destination from the text input control, and the gallery will display the results based on the search results, as shown below.
Output:
Power Apps StartsWith Filter
In the same way, if you want to filter the gallery control records using the Power Apps StartsWith() function, you need to specify the or (||) operator. Apply the below formula on the gallery’s Items property as:
Items = Filter(
colVacations,
StartsWith(
Title,
txt_Destination.Value
) || StartsWith(
Title,
txt_Destination.Value
)
)
Finally, Preview the app. The gallery filters and displays each record from the SharePoint list records based on the text input search results, like the one below.
This way, you can work with the “Power Apps StartsWith Filter.”
Power Apps StartsWith Wildcard
To work with Power Apps StartsWith wildcard, check out the below Power Apps forum link:
Check Out-> Power Apps Search function by using wildcards
I trust you find this Power Apps tutorial helpful. If you have any requirements related to the Power Apps StartsWith and EndsWith functions, You follow this tutorial till the end with useful examples to get an idea of how to work with both StartsWith and EndsWith functions.
Additionally, you may like some more Power Apps articles:
- Power Apps AddColumns Function
- Power Apps Get Office 365 Group Members
- Power Apps Toggle Control
- Power Apps Sum Column Examples
- Power Apps If Statement Examples
- Power Apps Today Date Without Time
- Power Apps Rating Control
- PowerApps Replace Character in String
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com