Power Automate string functions let you build, inspect, split, clean, and compare text inside a flow. Add an action such as Compose, open its Expression editor, and enter functions such as concat(), split(), replace(), or toLower() to transform dynamic content before using it elsewhere.
What string functions do in Power Automate
A string is text: an email address, a name, a subject line, an order number, or a sentence from a form response. Power Automate expressions can manipulate those values while a cloud flow runs. For example, a flow might remove extra spaces from a submitted name, extract a code from a subject line, or assemble a standard greeting from a person’s first name.
These functions belong to the expression language used by Power Automate cloud flows. They are different from Excel formulas, programming-language methods, and actions offered by individual connectors. A function transforms or checks a value; the surrounding flow decides when to run it and where to send its result. That distinction matters because connector data may arrive as a number, an array, an object, or a missing value rather than as the text you expected.
Expressions are most useful when dynamic content needs a repeatable transformation. If a connector already supplies the exact value you need, adding a string expression can make the flow harder to maintain without improving it. Use an expression when it solves a specific text-handling problem.
Where to enter an expression
In a cloud flow, add an action that accepts input, such as Data Operations – Compose, and select its input field. In the dynamic content pane, choose the Expression tab, enter the expression, and confirm it. For example, enter concat('Hello, ', triggerBody()?['Name']) to combine a greeting with a Name field from the trigger. The precise field path depends on the trigger and the data it provides.
Compose is a handy place to build and inspect an intermediate value, but an expression can also go directly into a compatible field in another action. In the flow designer, expressions are generally entered without a leading @. The saved workflow definition may represent expressions with an @ prefix; that representation is not usually what you type into the Expression tab.
After saving, run the flow with representative sample data and inspect the run history. Open the action’s inputs and outputs to see what value was actually passed and returned. This is especially useful when a dynamic-content token looks like plain text in the designer but turns out to contain a null, an unexpected space, or a different structure at runtime.
Useful functions for building and cleaning text
Several functions cover common text tasks. In the examples below, literal text is enclosed in single quotes, and dynamic content can be supplied in place of a literal value.
concat('Order ', '4821')joins text pieces and returnsOrder 4821. It is useful for greetings, labels, and identifiers assembled from multiple values.replace('red;blue;green', ';', ', ')replaces matching text and returnsred, blue, green. It replaces occurrences of the search text in the input.trim(' Jordan Lee ')removes whitespace at the beginning and end of a string, returningJordan Lee. It does not remove spaces between words.toLower('ALERT')andtoUpper('alert')change the letter case, returningalertandALERTrespectively.length('Power Automate')returns the number of characters, including the space:14.
For comparisons where letter case should not affect the result, normalize the values before comparing them. For example, compare toLower() applied to both an incoming email address and the expected address. This makes the intended behavior clear rather than relying on a reader to infer how differently cased values should be treated.
Extracting parts of a string
Use substring() when you know the position and length of the text to extract. Positions start at zero, so the first character is position 0, not position 1. For example, substring('Flow-2026-041', 5, 4) returns 2026. This is practical for consistently formatted codes, but it is fragile if the source text changes length or layout.
Use split() when a known delimiter separates the pieces. split('red;blue;green', ';') produces an array containing three items: red, blue, and green. To get the first name from a full-name field that is separated by spaces, an expression could be first(split(triggerBody()?['FullName'], ' ')). That simple approach assumes the field is present and that the first space separates the desired parts; names do not always follow that pattern.
indexOf() finds the position of a piece of text. For example, indexOf('ticket-4821', '-') returns 6. A flow can use that position as part of a later extraction, but check that the delimiter exists before depending on it. When the source format is predictable, splitting on a delimiter can be easier to understand than combining several position calculations.
Choosing the right approach for a text task
Choose a function based on the shape of the problem, not just on the fact that the input is text. A simple way to decide is to ask what the result should be:
- To join several pieces into one value, use
concat(). - To standardize outer whitespace or letter case, use
trim(),toLower(), ortoUpper(). - To change a known piece of text, use
replace(). - To divide a value at a known separator, use
split(). - To extract a fixed-position segment, use
substring(). - To count characters or locate a marker, use
length()orindexOf().
For example, if an incoming subject is Case: 1842 - Delivery delay, replacing a known prefix may be appropriate if the format is fixed. If the goal is to capture everything after a colon, a delimiter-based approach may be more adaptable, but the flow must account for missing or repeated colons. A complex expression is not automatically more robust: a clear series of Compose actions can make each transformation easier to inspect and troubleshoot.
Working with dynamic content and unexpected values
A common misconception is that every value shown in a dynamic-content list is ready to use as a string. A connector may return a number, a Boolean, an array, or an object. When a function expects text, convert a value deliberately where needed, for example with string(). For a numeric order identifier, a Compose expression such as concat('Order ', string(triggerBody()?['OrderNumber'])) makes the conversion explicit.
Missing and empty values also need a decision. A blank optional form field may be acceptable, while a missing customer identifier may mean the flow should stop or send an error notification. Functions such as empty() and coalesce() can help with checks and fallback values, but use them according to the data type and desired behavior. Do not assume that a missing field, a null value, and an empty string are interchangeable in every connector or expression.
Before building a long expression, consider whether a Condition action should check the input first. For instance, verify that a required field has a value before attempting to extract a substring from it. That can produce a more useful outcome than allowing a text operation to fail and leaving the run history to reveal the problem afterward.
Common errors and ways to prevent them
String expressions often fail because the input differs from the assumed format. A substring position can be out of range when a value is shorter than expected. A split operation can produce a different number of pieces when a delimiter is absent or repeated. A function can also fail or return an unintended result when it receives a null or a value of the wrong type.
- Test typical, shortest, longest, blank, and malformed examples, not just one successful run.
- Check the actual action output in run history before assuming the source field contains the expected text.
- Use a Condition to handle required values and unusual formats before applying a transformation.
- Break a long expression into Compose actions with meaningful names so each intermediate result is visible.
- Use clear delimiters and document assumptions, such as whether a code always has a fixed length.
Be careful with expressions copied from another flow. A reference such as triggerBody()?['Name'] only works if the current trigger exposes a field with that name and structure. A trigger schema can differ from a connector’s output, even when both display a field called Name. Re-selecting dynamic content or checking a sample run can help establish the correct reference.
Cloud flows, desktop flows, and practical limits
Power Automate cloud flows use the workflow expression language in action fields and commonly pair it with connectors, triggers, and built-in data operations. Power Automate for desktop is a separate environment for automating desktop tasks. It has its own actions for working with text variables, and cloud-flow expressions should not be assumed to work identically in desktop-flow fields. Confirm which product and action you are using before adapting an example.
String functions transform values; they do not replace a decision about data quality or a connector’s own capabilities. If a SharePoint, Outlook, or other connector has a field that already provides the desired value, use that value where possible. If the task involves parsing a complicated document, interpreting natural-language meaning, or handling many irregular formats, a chain of basic string functions may be the wrong tool. A dedicated connector, structured input, or a more suitable processing step can be easier to maintain.
There is no separate charge for writing a particular string expression, but the flow’s overall licensing and usage depend on its connectors, plan, and environment. A string function does not make a premium connector free or change the licensing rules that apply to the flow. Check current Microsoft licensing information for the specific connectors and usage involved.
Frequently Asked Questions
What are string functions in Power Automate?
They are expression functions that manipulate or inspect text in a flow. Examples include concat() for joining text, replace() for substitutions, and split() for dividing text at a separator.
How do I combine text and dynamic content?
Use concat() in the Expression tab. For example, concat('Hello, ', triggerBody()?['Name']) joins a greeting with the Name value, provided that the trigger has that field.
How can I remove spaces from a Power Automate string?
Use trim() to remove whitespace at the start and end of a value. It does not remove spaces between words. To remove or replace a specific character throughout text, use replace() with the character you want to change.
How do I split a string into separate values?
Use split() with the source text and its delimiter, such as split('A|B|C', '|'). The result is an array. Use an array-oriented action or an expression such as first() when you need a particular item.
Why does a string expression fail in my flow?
Check whether the value is missing, a different type, or formatted differently from what the expression expects. Also verify field references and delimiter positions in run history, then test blank and irregular inputs as well as normal ones.
Related
- How to Use SUBTOTAL in Excel
- X-Arcade Programming Software: What You Need to Know
- Line of Balance Schedule: How It Works on Projects
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Updating Data Validation Lists in Excel the Right WayTo update an Excel drop-down list, select a cell that uses it, choose Data > Data Validation, and…
- Excel Autofill vs Flash Fill: How to Choose the Right ToolExcel AutoFill extends a series or copies cell contents, while Flash Fill recognizes a pattern in your examples…
- Excel Percentage Difference Formula: How to CalculateFor the percentage difference between two nonnegative values in Excel, use =ABS(B2-A2)/AVERAGE(A2,B2), then format the result as a…
- BMI Calculator Excel Formula: Steps, Examples, and TipsTo calculate BMI in Excel, divide weight in kilograms by height in meters squared. If weight is in…
- Round Excel to Significant Figures: Formulas and MethodsTo round a number in Excel to a chosen number of significant figures, put the value in A2…
- Excel Percentage of Cells with Text: 2 FormulasThe quickest way to find the percentage of cells containing text in Excel is to use =COUNTIF(range,"*")/COUNTA(range) for…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.