While working on a client’s requirement, I was assigned a task to extract the file name from the file path that is stored locally on the desktop. This is similar to getting a substring from a string in Power Automate Desktop.
Power Automate desktop provides a set of text functions that enable you to perform various text manipulations.
In this tutorial, I will explain how to extract a substring from a text string using Power Automate Desktop by using the actions below.
- Using the Get Subtext action
- Using the Crop text action
Extract Substring from String Using Get Subtext in Power Automate Desktop
Assume I have a text string as follows: “The United States is also commonly referred to as the USA.” I wanted to extract a part of the string from it, specifically [USA].
To achieve this, we can use Text actions, such as Get Subtext and Parse Text, etc, in Power Automate Desktop.
Do follow the steps below to know how to extract a substring from a string in PAD:
- Open your Power Automate desktop app, tap on the + New drop-down, and add a Flow. Enter the flow name and click on the “Create” button.

- Next, from the Action Pane, drag and drop the “Set Variable” action. Provide a text string value in the Value parameter. Click on the Save button. It will produce a variable named ‘NewVar‘.

- After that, add one more Set variable action to store the string value that we need to extract. Here, I wanted to extract [USA] from a text. Save the action.
- I have renamed the variable produced to “Substring“.

To retrieve the substring, I need to determine the character position of [USA]. We can get the text position by parsing the text.
- To do that, add a “Parse text” action that is present under the Text variable. Set the parameters below and click the Save button.
- Text to parse: Select NewVar variable.
- Text to find: Choose Substring variable.
- Start parsing at position: Enter the value as 0.
- First occurrence only: Toggle on the button.
You can rename the Variables produced from this action. I have renamed it to “StringPosition“.

- Then, add a “Get subtext” action that will extract the substring from a string based on the start index and length. Enter the parameters and click on Save.
- Original text: Click on {x} -> Select NewVar variable.
- Start index: Select Character position from the options.
- Character position: Choose to add the StringPosition variable.
- Length: Take the End of text option. You can add as needed.
Here, I have renamed the variable produced to ExtractedSubtext.

- After that, to display the extracted text from a string, drag and drop the “Display message” action. Make sure to provide the parameters below and click on the Save button.
- Message box title: Enter the title for a message box.
- Message to display: Add ExtractedSubtext variable.

- The flow is ready now. Save and run the flow.
- When the flow is executed successfully, you can see that the extracted substring will be displayed in the message box. You can refer to the screenshot below:

This is how you can dynamically extract a substring from a text using Power Automate Desktop.
Check out Find and Replace Text in Power Automate Desktop
Get Subtext from Text in Power Automate Desktop using Crop Text
Here, I will extract the subtext from a text string using the “Crop text” action in Power Automate Desktop.
I will use the exact text string as in the above example, but now my requirement is to retrieve “United States of America” from a provided string.
Text String:
The United States of America is also commonly referred to as the USA
Check out the steps below:
- As the first step, store the original text string in a “Set variable“. Here, it will produce a variable named ‘NewVar’.

- Then, under the Action Pane, search for the “Crop text” action and drag and drop it to the workspace. This will retrieve the text value that occurs before, after, or between the specified texts.
- Original text: Select the variable from the previous action.
- Mode: I have chosen the ” Get text between the specified flags option. Select according to your need.
- Start flag: Provide the start text.
- End flag: Provide the end text.
This action will produce “CroppedText” as a variable. Then, click on the Save button.

- To display the cropped text, take the “Display message” action. Ensure to set the parameters. Then, save the action.
- Message box title: Enter the title for a message box.
- Message to display: Add ExtractedSubtext variable.

Save and run the flow by clicking on the save icon.
Output:

Thus, you can use the Get subtext action and the Crop text action to extract a substring from a text string using Power Automate Desktop.
In this tutorial, I explained how to extract a substring from a string in Power Automate Desktop using different flow actions such as the Get Subtext action and the Crop text action.
I hope you liked reading this article. Please share your suggestions or comments in the comments section below.
You may also like the following tutorials:
- Power Automate Extract String
- Power Automate Desktop Extract Data from Excel
- Power Automate Desktop Insert Row in Data Table
- Extract Tables from a PDF Power Automate Desktop
- Insert Column and Row into Excel Worksheet using Power Automate Desktop
- Export and Import Power Automate Desktop Flows

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.