The split() function in Power Automate takes a text string and breaks it into an array of substrings based on a delimiter. Its syntax is split('text', 'delimiter') — for example, split('a,b,c', ',') returns ['a','b','c']. This is one of the most frequently used string functions in Power Automate, especially when parsing CSV data, email bodies, or multi-value inputs.
Background: Why split() exists in Power Automate
Power Automate (formerly Microsoft Flow) is a cloud-based automation tool that lets you connect apps and services. When you pull data from sources like SharePoint, Outlook, or SQL Server, you often get a single text string that contains multiple values separated by a delimiter (comma, semicolon, pipe, etc.). The split() function lets you convert that string into an array so you can loop through items, filter them, or use them in other expressions. It is equivalent to the split() function in programming languages like Python or JavaScript, but with a simpler syntax tailored for flow expressions.
How split() works: Syntax and parameters
The function takes exactly two arguments:
- Text (string): The source string you want to split. It can be a literal string in quotes, a variable, or a dynamic content expression.
- Delimiter (string): The character or substring that separates the pieces. It can be a single character like a comma, or a multi-character string like
', '(comma+space). The delimiter is case-sensitive and is removed from the output.
Example with a dynamic value: if you have a variable named myText containing apple;banana;cherry, the expression split(variables('myText'), ';') returns ['apple','banana','cherry']. The result is an array, which you can then use in an Apply to each loop or with functions like length() or first().
Choosing the right delimiter and handling empty values
Selecting a delimiter is critical. If your data uses commas, but some fields contain commas within quotes (e.g., CSV with quoted fields), a simple split on comma will break. In such cases, you may need to preprocess the data or use a different delimiter. Also, note that split() does not skip empty entries: split('a,,b', ',') returns ['a','','b']. If you need to ignore empties, you can filter the array afterwards using filter() or a loop with a condition.
For example, to remove empty strings from the result, you could use:
filter(split(variables('myCSV'), ','), @not(equals(item(), '')))
This expression works in Power Automate’s expression editor, where item() refers to each element of the array.
Common problems and troubleshooting
Several issues arise frequently when using split():
- Delimiter not found: If the delimiter does not appear in the text,
split()returns an array with one element — the entire original string. This may be unexpected, so check your data. - Case sensitivity:
split('A,B', 'a')returns['A,B']because ‘a’ is not found (uppercase vs lowercase). UsetoLower()if you need case-insensitive splitting. - Whitespace: If your delimiter is a comma but your data has spaces after commas (e.g.,
'a, b, c'), splitting on','gives['a',' b',' c']with leading spaces. Usetrim()on each item if needed. - Null or empty input: If the text is null or empty,
split()returns an array with one empty string. You can guard with a condition or usecoalesce()to provide a default.
Practical examples and use cases
Here are three common scenarios where split() is used:
- Parsing a comma-separated list from a SharePoint column: Suppose a SharePoint list column contains
'red, green, blue'. You can split it and loop through each color to send an email or create tasks. - Splitting a full name into first and last: If you have
'John Doe',split('John Doe', ' ')gives['John','Doe']. You can then usefirst()andlast()to get the parts. - Extracting values from a URL query string: For a URL like
https://example.com?id=123&name=test, you can split on'&'to get key-value pairs, then split each pair on'='.
Example expression to get the second item from a split: split('a,b,c', ',')[1] returns 'b' (index 0 is the first).
Alternatives and related functions
While split() is the primary tool, there are related functions you might consider:
- substring(): Extracts a fixed portion of a string based on start index and length. Useful when you know the exact position.
- replace(): Replaces all occurrences of a substring with another. You could replace a delimiter with a newline to make a multi-line text.
- union() or intersection(): For array operations, but not directly for splitting.
- json(): If your data is in JSON format, you can parse it directly instead of splitting.
For example, to split a string by multiple delimiters (e.g., comma or semicolon), you could first use replace() to normalize delimiters to one, then split. For instance, split(replace('a;b,c', ';', ','), ',') gives ['a','b','c'].
Cost and performance considerations
Power Automate licensing is based on plan (e.g., Microsoft 365 includes a limited number of flows, or standalone plans like Per-user or Per-flow). The split() function itself does not incur extra cost, but the number of actions in a flow might affect your API request limits. Each time you call split() inside a loop, it counts as an action, which can consume your daily request quota. To optimize, try to split once outside a loop and store the result in a variable. Also, be aware that large strings (e.g., >100KB) might hit expression evaluation limits. For very large data, consider using a different approach like a data operation action or a custom connector.
Safety and best practices
When using split(), always validate the input. If you are splitting user-provided text, ensure the delimiter is not user-controlled to avoid unexpected results. Also, be cautious with special characters: if your delimiter is a backslash or a regex special character, it is treated literally, so no escaping is needed. However, if you are using a multi-character delimiter, make sure it is exactly as it appears in the text. Finally, test your expressions with sample data in the expression editor before deploying the flow.
Frequently Asked Questions
How do I split a string by newline in Power Automate?
Use split(variables('text'), '
') where
is the newline character. In the expression editor, you can type split(variables('text'), decodeUriComponent('%0A')) or use the literal newline by pasting a line break. Note that the delimiter must match the exact line ending (Windows uses , so you may need
split(text, decodeUriComponent('%0D%0A'))).
Can I split a string into characters?
Yes, use an empty string as the delimiter: split('hello', '') returns ['h','e','l','l','o']. This works because the delimiter is an empty string, and Power Automate splits between each character.
What happens if the delimiter appears at the beginning or end of the string?
If the delimiter is at the start, the first element will be an empty string. Similarly, if it is at the end, the last element will be empty. For example, split(',a,', ',') returns ['','a','']. You may need to filter out empty strings if they are not desired.
Is split() case-sensitive?
Yes, the delimiter is case-sensitive. If you need to split on ‘a’ regardless of case, convert both the text and delimiter to lowercase first: split(toLower(text), toLower(delimiter)).
Can I use split() inside a condition?
Yes, you can use the result in a condition. For example, to check if an array contains a specific value, use contains(split(text, ','), 'target') in a condition expression.
Related
- Shortcut to Lock System: Fastest Ways on Windows & Mac
- BETWEEN in BigQuery: Syntax, Examples & Gotchas
- Refresh PivotTable Data? How to Update in Excel
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Open a Numbers File in Excel: Step-by-Step GuideTo open an Apple Numbers file in Excel, first convert it to an Excel workbook (.xlsx): use File…
- How to Insert a Checkbox in Word With a TickTo put a tick in a Word checkbox, insert a checked-box symbol for a fixed mark, or add…
- Merge Cells in Excel Using Keyboard: Shortcuts & StepsIn Excel for Microsoft 365 on Windows, select the cells you want to combine, then press Alt, H,…
- How to Copy in Excel While Skipping Blank Cells SafelyTo copy cells in Excel without replacing existing destination values with blanks, copy the source range, select the…
- Excel Text to Number: Reliable Ways to Convert ValuesTo convert text-formatted numbers in Excel, select the cells and choose the warning icon’s Convert to Number option,…
- How to Format a Set Number of Digits in ExcelTo show a number with a fixed minimum number of digits in Excel, select the cells, press Ctrl+1,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.