Power Automate Desktop String Functions Explained

Formulas & functions · Updated November 22, 2026

Power Automate Desktop provides a set of string functions—such as Substring, IndexOf, Replace, ToUpper, and Trim—that let you manipulate text inside your desktop flows. These functions are used in expressions within actions like “Set variable” or “Condition”, and they follow a syntax similar to Excel or programming languages, making them essential for cleaning data, parsing file paths, or building dynamic messages.

What Are String Functions in Power Automate Desktop?

String functions are built-in operations that act on text values. In Power Automate Desktop (PAD), they are part of the expression language you can use in any action that accepts a text input. Instead of writing complex logic manually, you call a function like Substring to extract part of a string, or Split to break text into a list. These functions are case-sensitive by default unless you use a variant that ignores case (e.g., IndexOf vs. IndexOfIgnoreCase).

PAD supports dozens of string functions, including Concat, Contains, EndsWith, StartsWith, Length, Lower, Upper, Substring, Replace, Trim, PadLeft, PadRight, Remove, Reverse, and text extraction functions like Regex.Match. Each function returns a specific type—usually text or a number—so you can chain them together in nested expressions.

How to Use String Functions in Desktop Flows

You use string functions directly in the expression editor of actions. For example, to get the first five characters of a variable named FileName, you would set a variable with the expression Substring(FileName, 0, 5). The expression editor appears in fields marked with an fx icon. When you type a function name, a tooltip shows its parameters and expected types.

Here is a simple step-by-step example:

  1. Create a variable named FullName with value "John Doe".
  2. Add a “Set variable” action and name the output FirstName.
  3. In the value field, enter Substring(FullName, 0, IndexOf(FullName, " ")).
  4. Run the flow. The FirstName variable will contain "John" because IndexOf finds the position of the space (4), and Substring takes characters from index 0 to 4.

Note that string indexes are zero-based, meaning the first character is at position 0. This is consistent with most programming languages but differs from some user interfaces that count from 1.

Common String Functions and Their Syntax

Here are the most frequently used string functions in PAD, with a brief description and an example of each:

  • Substring(Text, StartIndex, Length) – extracts a portion. Example: Substring("Hello World", 6, 5) returns "World".
  • IndexOf(Text, SubText) – returns the zero-based position of the first occurrence. Example: IndexOf("apple pie", "pie") returns 6.
  • Replace(Text, OldText, NewText) – replaces all occurrences. Example: Replace("cat cat", "cat", "dog") returns "dog dog".
  • Contains(Text, SubText) – returns true if the text contains the substring. Example: Contains("Microsoft", "soft") returns true.
  • ToUpper(Text) and ToLower(Text) – change case. Example: ToUpper("hello") returns "HELLO".
  • Trim(Text) – removes leading and trailing spaces. Example: Trim(" hi ") returns "hi".
  • Split(Text, Delimiter) – splits into a list. Example: Split("a,b,c", ",") returns a list with three items.
  • Length(Text) – returns the number of characters. Example: Length("hello") returns 5.

Many functions have an IgnoreCase variant. For instance, IndexOfIgnoreCase searches without considering case, which is useful when user input may vary.

Choosing the Right Function for Your Task

Selecting the correct function depends on what you want to do. If you need to extract a fixed number of characters from the start, use Substring with a constant length. If you need to find where a pattern begins, use IndexOf or Regex.Match for more complex patterns. For cleaning data, Trim and Replace are your primary tools. When building dynamic messages, Concat (or the & operator) combines strings.

For example, to extract the file extension from a filename, you could use Substring(FileName, IndexOf(FileName, ".") + 1, Length(FileName) - IndexOf(FileName, ".") - 1). This works but is verbose. A simpler approach is to use Split and take the last item, or use the Regex.Match function with a pattern like \.(\w+)$.

Common Pitfalls and Mistakes

One frequent error is off-by-one mistakes with indexes. Since indexes start at zero, the last character is at Length(Text) - 1. Forgetting this leads to wrong substrings. Another issue is using IndexOf when the substring is not found; it returns -1, which can cause Substring to fail. Always check for -1 before using the result.

Case sensitivity also trips users. IndexOf is case-sensitive, so searching for “hello” in “Hello” returns -1. Use IndexOfIgnoreCase if you need case-insensitive matching. Also, Replace replaces all occurrences, not just the first. If you only want to replace the first instance, you need to combine IndexOf and Substring.

Finally, remember that string functions return text or numbers, but not booleans unless the function is a condition like Contains. In a “Condition” action, you can directly use Contains(Variable, "text") as the condition.

String Functions vs. Text Actions

PAD also provides dedicated text actions like “Extract text”, “Replace text”, and “Trim text” in the “Text” group of actions. These actions are visual and generate the underlying expressions automatically. The difference is that actions are easier for beginners, but expressions give you more flexibility and can be used anywhere, including inside loops or conditions. For example, a “Replace text” action has separate fields for old and new text, while the Replace function can be embedded in a larger expression. If you are comfortable with the syntax, using functions directly often makes flows more compact.

Performance and Limitations

String functions are fast for typical text lengths. However, if you process very large strings (e.g., entire files), consider using file actions or streaming to avoid memory issues. There is no hard limit on string length in PAD, but extremely long strings may slow down the flow. Also, some functions like Regex.Match can be computationally expensive if the pattern is complex; use them sparingly.

Another limitation is that PAD expressions do not support loops or custom functions. For repeated operations, you would use a loop action and call the function inside it. For advanced text parsing, consider using the “Run script” action with PowerShell or VBScript, but that adds complexity.

Alternatives and Related Tools

If you need more advanced string manipulation, you can use the “Run script” action to execute PowerShell, which gives access to .NET string methods like Regex.Replace or String.Format. For example, to format a date into a custom string, PowerShell’s -f operator is handy. However, for most automation tasks, the built-in functions are sufficient.

Another alternative is to use the “Text” actions, which are essentially wrappers around the same functions. Finally, if you are working with structured data like JSON, consider using the “Parse JSON” action and then access properties directly, rather than parsing with string functions.

Frequently Asked Questions

How do I concatenate two strings in Power Automate Desktop? Use the Concat function or the & operator. For example, Concat("Hello ", "World") returns "Hello World". You can also use "Hello " & "World".

Why does IndexOf return -1? IndexOf returns -1 when the substring is not found. This is normal. Always check the result before using it in Substring to avoid errors. For case-insensitive search, use IndexOfIgnoreCase.

Can I use string functions inside a loop? Yes, you can use them in any expression, including inside loops. For example, you can call Substring on each item in a list by referencing the loop variable.

Is there a function to reverse a string? Yes, the Reverse function reverses the order of characters. Example: Reverse("abc") returns "cba".

How do I remove a specific character from a string? Use Replace with an empty string as the replacement. For example, Replace("a-b-c", "-", "") returns "abc".

What is the difference between Substring and Remove? Substring extracts a portion of the string, while Remove deletes a portion starting at an index. For example, Remove("Hello World", 6, 5) returns "Hello " because it removes characters from index 6 to 10.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.