Power Automate IndexOf() Function

Do you want to know how to get a character position or string position in Power Automate? In this tutorial, I have explained how to do this by using the Power Automate indexof function.

I will show you the syntax of IndexOf() function in Power Automate, and also two Power Automate indexof examples.

Power Automate IndexOf() Function

Power Automate indexOf() function returns the position of the first occurrence of a string, from a given string. IndexOf() function returns the first true match of a given string. This function also includes spaces as a count position.

This function is essential to find the position of a string or a character from the provided string value. The indexOf() function consists of two components such as the lastIndexOf() and nthIndexOf().

IndexOf() Function Syntax

This is the syntax for the indexOf() function that can be used inside a Power Automate flow.

indexOf(['text'],'Search text ')

Note: The first character on the position of ‘0’ not starts with ‘1’.

Example: indexOf([‘Joni Sherman’], ‘Sherman’) => Index position for ‘Sherman’ is ‘5’. If the search text is ‘Joni’, then the index position is ‘0’.

The return value is an integer where the search text will appear for the first time in a given text.

Note: If the serach text not found in the given text, then it will return the output as [-1].

IndexOf() Function Examples in Power Automate

Let’s dive into the indexOf() function by implementing it in a Power Automate flow.

So, now, I will explain how to implement the indexOf() function in a Power Automate ‘Instant cloud flow’ that will trigger manually.

Follow the below-mentioned steps to create a flow that will work with the indexOf() function:


1. Navigate to make.powerautomate.com in the browser. In the Power Automate Home page, click on “+Create” -> select “Instant cloud flow” -> set Flow name -> choose “Manually trigger a flow” -> click on Create.

  • In the trigger add a Text input box to provide the text manually.
power automate indexof

2. Then, add an ‘Initialize variable’ flow action to provide the Name, Type, and Value for the variable.

power automate indexof function

3. Next, add the ‘Compose’ data operation to return the output of the indexOf() function inside a flow.

  • Inputs: Add the below-provided expression and replace the text value.
power automate get index of string

4. Now, it is time to save and test the flow. Click on Save and select Test. Test it Manually.

indexOf() function in Power Automate

5. Finally, when the flow runs successfully, the outputs of the compose flow action will display returns of the indexOf() function for the given string as shown below.

  • In the Run flow box, I have given the text as ‘Joni Sherman’.
power automate find position in string

This is how to use the indexOf() string function in a Power Automate flow.


Now, I will discuss another example of a Power Automate string function i.e., indexOf() function, by using a SharePoint list.

Recently, When I was working on a SharePoint list, I got a requirement from one of our clients to find a character index or a string position of a text column value.

For that, I have used a SharePoint list named ‘HR Policies’ with the columns as presented in the table below.

Column NameDatatype
Employee NameIt is a single line of text – Title column
Policy AppliedSingle line of text
Started DateA single line of text
power automate find position in string

In the SharePoint list mentioned above, we need to find out the character index or string position based on the list column i.e., Policy Applied.

To implement it, let’s create a Power Automate ‘Automated cloud flow’ that will trigger automatically.

Follow the below steps to create the flow:

1. Open a Power Automate home page, click on +Create -> Select “Automated cloud flow” -> Provide flow name, choose a trigger ”When an item is created” -> Click on Create. Set details like Site Address and List Name.

power automate indexof example

2. After that, add an ‘Initialize variable’ flow action to store the values of a text column. Give the details for a variable.

  • Name: Give a name for an initialized variable.
  • Type: Select datatype as ‘String’ from drop-down.
  • Value: Add the list column from the dynamic content.
power automate find index of string

3. To see the results of the indexOf() function, add the ‘Compose’ flow action and provide the below-given expression in the ‘Inputs’ section.

indexOf(variables('Applied Policy'),'Policy')
indexOf() in Power Automate flow

4. At this point, save and test the flow manually. Click on Save and Test.

How to use the Power Automate indexOf() function

5. Then, the outputs of the compose data operation will show the index number for a ‘Policy’ in the provided string, as shown in the figure below:

Power Automate indexOf() function

This is how to use the indexOf() string function in a Power Automate flow to get index of a string.


When finding a character index or a string position from a text string, a user can use the indexOf() function in Power Automate. I hope from this tutorial, you understood how to use the indexOf() function in Power Automate. I have also shown you two Power Automate indexof examples.

You can also check: