Do you want to learn about the indexOf() string function, particularly the LastindexOf() function in Power Automate? In this tutorial, I have explained how to use the Power Automate lastindexof function with syntax and examples.
Power Automate lastindexOf() function will return the index of the last occurrence of a string from a given string. This function also includes spaces as a count position.
Power Automate LastindexOf Function
Power Automate the lastindexOf() function will return the index of the last occurrence of a string from a given string. This function also includes spaces as a count position. And the output of the lastindexOf() will always return as ‘Number’.
This is one of the Power Automate string functions included under the indexOf() function. It will be useful to find out the index of those characters or string that comes repeatedly.
The index of a character will be started at '0'. If the character or a text is not found, then it will return the output as '-1'.
LastindexOf() Function Syntax
The syntax of the lastindexOf() function in Power Automate is:
lastindexOf(['text'],'Search text ')
Example: lastIndexOf(Power Platform has four major components Power BI, Power Apps, Power Automate and Power Virtual Agents),’Power’) => It will return the last index of power, i.e. (82).
lastindexOf(Henrietta Muller),’e’) => Return the output as ’14’ because in the given text i.e., ‘Henrietta Muller’ lastindexOf() function finds out the last repeated character position of ‘e’.
lastindexof Power Automate Examples
Here, I will explain how to use the lastindexOf() function in a Power Automate, by implementing it in a manual trigger flow of Power Automate.
Follow the below-mentioned steps to create a flow that will work with the lastindexOf() function:
Example:-1
1. Navigate to make.powerautomate.com in the browser. In the Power Automate Home page, click on “+Create” -> select “Instant cloud flow” ->In the next window, set Flow name -> choose “Manually trigger a flow” -> click on Create.
- Add a text input box in the trigger to provide the text manually.

2. Then, add an ‘Initialize variable’ flow action to store the value of a text during the flow. Set Name, Type, and Value for a variable.

3. In the next step, add a ‘Compose’ data operation to give the expression of lastindexOf() function. Add the details:
- Inputs: Provide the below given expression here.
lastIndexOf(variables('Name'),'e')

4. Now, the flow has been created. Click on Save and Test. Test the flow Manually.

5. In the Run flow window, I was given the text input (Henrietta Muller) -> Click on the ‘Run flow’ button as shown below.

5. Now, the outputs of a compose data operation will return the last index of a character or a text from the provided text.

This is how to use the lastindexOf() string function in a Power Automate flow.
Example:-2
Here, I will explain one more example of the Power Automate lastindexOf() function based on a SharePoint list.
Recently, when I was working with a SharePoint list, I got a task to find the last index of a text or character based on a SharePoint list column using Power Automate flow.
To do that, I have created a SharePoint list named ‘HR Policies’ with different columns, as represented in the table below.
Column Name | Datatype |
Employee Name | It is a Single line of text – Title column |
Policy Applied | Single line of text column |
Policy Description | Single line of text column |

From the above given SharePoint list, I need to find out the last index of a particular string from the given text based on the list column i.e., Policy Description.
To achieve this, let’s build an ‘Automated cloud flow’ in Power Automate that will trigger when an item is created in a SharePoint list.
Follow the below steps:
1. For creating an ‘Automated cloud flow’, follow: Browse https://make.powerautomate.com -> In the Power Automate Home page, click +Create -> Select ‘Automated cloud flow’.
In the next window, set the Flow name, choose ‘When an item is created’ trigger -> Click Create. Provide the below details inside the trigger.
- Site Address: Select a SharePoint site from the drop-down.
- List Name: Choose a specific SharePoint list from the drop-down.

2. Under the trigger, add an ‘Initialize variable’ flow action to store the values of a list column during the flow. Set the details for a variable as below:
- Name: Give the name manually.
- Type: Select datatype from the drop-down.
- Value: Take value from the dynamic content.

3. Then, add a ‘Compose’ data operation to include the lastindexOf() string expression along with the variable and search text.
- Inputs: In the inputs, add the below given expression placed in the code.
lastIndexOf(variables('Description'),'Policy')

4. It is the time for the flow to save and test it. So, click on Save and Test the flow -> Test the flow Manually.

5. When the flow runs, add an item to the SharePoint list. If there are no errors, the flow runs successfully.
Open the compose flow action to display the last index of a search text from the given text like the screenshot below:

This is how to use a Power Automate lastindexOf() function, to find out the last index of a character, text, or string based on a SharePoint list column.
Conclusion
In this Power Automate tutorial, I have explained how to use the Power Automate lastindexof function, its syntax and also I have show two examples of lastindexof function in Power Automate.
You may like the following tutorials:
- Power Automate startswith Function
- Length Function in Power Automate
- Power Automate Contains() Function

Preeti Sahu is an expert in Power Apps and has more than 6 years of experience working with SharePoint and the Power Platform. As a Power Platform expert for Power BI, Power Apps, Power Automate, Power Virtual Agents, and Power Pages, she is currently employed with TSinfo Technologies. She is the author of the book Microsoft Power Platform A Deep Dive. She also made a big technical contribution to SharePointDotNet.com in the form of articles on the Power Platform. She enjoys traveling and spending time with her family in her spare time.