In this tutorial, I will explain the Power Automate slice() function, its syntax, and how to use the slice function in Power Automate with various examples.
slice() Function in Power Automate
The Power Automate slice() function extracts a piece of text or a part of a string from the provided text in a flow. The Power Automate slice() function is an enhanced version of the substring() function that cuts the string based on the start and end indexes.
This function is similar to the Power Automate substring() function, which both return the contents of a string. However, the substring() function differs in parameters like the start index and the length of the Substring.
In the Power Automate slice() expression, we can also pass the negative values in the startIndex parameter, which will take the count of index position from the backward, i.e., end of the string.
Example:[slice(‘Lidia Holloway’, -6)] => Return “lloway.”
Power Automate slice function Syntax
The syntax for a Power Automate slice() function looks like this:
slice('[text]', [startIndex], [endIndex])Example of Power Automate slice() expression: slice(‘Joni Sherman’, 0,4) => It will return “Joni”.
Parameters:
- Text: It is a mandatory field that has a substring to be identified.
- Start Index: This should be given as an integer that includes the starting position of a text from where the substring should be extracted. For example, the start index for’ Power Automate -> ‘P’ is ‘0’. Similarly, the start index for’ o’ is ‘1’, and for ‘A’ it is ‘6’.
- End Index: It is also an integer that includes the end position of a searching substring. The end index is optional. If it is not given in the slice() expression, it will return a string from the startIndex position to the endIndex position.
- Example: slice(‘Lidia Holloway’, 3) => Return the string like ” ia Holloway”.
Note: First character on the position of '0'It returns the value as a substring identified between the two numbers of the start index and the end index.
Power Automate slice() Function Examples
Here, I will explain examples of how to use the slice() function in Power Automate to extract a part of a string.
Example:-1
1. Navigate to make.powerautomate.com in the browser to open the Power Automate Home page -> Tap on +Create -> Select ‘Instant cloud flow’ -> In the next window, select a trigger ‘Manually trigger a flow’ and enter a flow name -> Click Create.
- Open the trigger -> Click Add an input -> Select Text.

2. To give the slice() expression in a flow, add an ‘Initialize variable’ flow action under the flow trigger. The Initialize variable stores the information, and the stored values can be used during the flow.
- In the initialized variable, give Name, Type, and Value.
Value: slice(triggerBody()['text'],0,4)
3. To view the output of the Power Automate slice() function, we can use the ‘Compose’ data operation. Add the ‘Compose’ data operation and give the value in the ‘Inputs’ section.

4. Now, the flow is ready to Save and Test. Click on Save. Test the flow Manually. In the Run flow window, Provide the text value -> Click on Runflow.

5. When the flow runs successfully, it will notify a message as ‘Your flow ran successfully.’ Then, open the ‘compose’ flow action to see the output. The output will be received as a substring from the given string between the indexes.

This is how to extract text from a string from Power Automate’s slice() expression.
Example:-2
Let me explain one more Power Automate’s slice() string example to get a string between two characters.
I will do this using a SharePoint list. The SharePoint list has a few columns, like Full Name and DOB. In this SharePoint list, we wanted to cut the string between two “Full Name” characters according to the requirement.
The screenshot shows the image of the SharePoint list:

Similarly, follow the steps mentioned in the above example to create a flow.
I will create an “Automated cloud flow” in Power Automate that will trigger automatically.
1. Log in to the Power Automate with Microsoft credentials. On the Power Automate Home page, tap +Create -> Select Automated cloud flow -> Enter Flow name, and select trigger. In the trigger, choose Site Address and List Name.

2. In a flow, add a flow action, i.e., ‘Initialize variable.’ Initializing a variable at the beginning of your flow can be used to modify, set, and retrieve its value as needed. Then, set the parameters as below:

3. Take a “Compose” data operation to check the value returned from the Power Automate slice() expression. In the “Inputs,” add the below value as given in the code.
slice(variables('Name'),0,6)
4. Now, make sure to Save the flow. Then, Test the flow Manually. After that, create a new item in the SharePoint list to see if the flow works.
5. The below image shows the output of a slice() function, which extracts text between two words in Power Automate flow based on the SharePoint list column ‘Full Name.’

This is how to use the Power Automate string slice() function to cut the text between the characters.
Conclusion
I trust this Power Automate tutorial, which teaches detailed information about the Power Automate Slice() Function, its syntax, and how to use it in a flow.
You may like the following tutorials:
- Power Automate Chunk() Function
- Power Automate Contains() Function
- Remove Line Breaks From Text in Power Automate
- Power Automate concat() Function
- Power Automate utcNow() Function

Preeti Sahu is an expert in Power Apps and has over six years of experience working with SharePoint Online and the Power Platform. She is the co-author of Microsoft Power Platform: A Deep Dive book. As a Power Platform developer, she has worked on developing various tools using Power Apps and Power Automate. She also makes Microsoft 365 videos and shares them on YouTube.