The Split function in a canvas app (Power Apps) takes a text string and breaks it into a table of substrings based on a delimiter you specify. For example, Split("apple,banana,cherry", ",") returns a single-column table with three rows: apple, banana, and cherry. This function is essential for parsing CSV data, handling multi-select values, and cleaning imported text.
Background: Why You Need Split
Canvas apps often receive data as delimited strings—from SharePoint choice columns, imported CSV files, or user input in a single text box. Without a way to break these strings apart, you cannot easily loop through individual items, filter them, or display them in a gallery. The Split function solves this by converting a flat string into a structured table that Power Apps can process like any other data source.
It is the opposite of the Concat function, which joins table values into a single string. Together they let you move between flat text and structured data without leaving the app.
How the Split Function Works
The syntax is straightforward: Split( Text, Separator ). The first argument is the string you want to break apart; the second is the delimiter—a character or sequence of characters that marks where splits occur. The result is always a single-column table with the column name Result.
Key behaviors to note:
- The separator is case-sensitive.
Split("A-B", "-")works, butSplit("A-B", "-")with a different case would not split. - If the separator appears multiple times, each occurrence creates a new row. Empty strings between consecutive separators are included as blank rows.
- If the separator is not found at all, the function returns the entire original string as a single row.
- You can use a multi-character separator, such as
"; "(semicolon plus space), to split on a pattern.
Example: Split("red; green; blue", "; ") returns a table with three rows: red, green, blue. If you accidentally use ";" instead, you get red, (space)green, (space)blue—notice the leading spaces.
Using Split with Other Functions
Split is rarely used alone. It shines when combined with functions that work on tables, such as First, Last, Filter, or ForAll.
For instance, to get the second item from a comma-separated list, you can use: Last( FirstN( Split(TextInput1.Text, ","), 2 ) ).Result. This takes the first two rows, then returns the last of those—effectively the second item.
To loop through each item and perform an action, use ForAll( Split(TextInput1.Text, ","), SomeFunction(Result) ). Inside the ForAll, the current row’s value is available as Result.
When you need to filter or search within the split results, wrap it in a Filter or use it directly in a gallery’s Items property: Items = Split(TextInput1.Text, ",") will display each item as a separate row in the gallery.
Common Problems and How to Avoid Them
The most frequent issue is accidentally including spaces in the separator. If your input is “apple, banana, cherry” and you split on “,”, you get rows with leading spaces: ” apple”, ” banana”, ” cherry”. To fix this, either split on “, ” (comma plus space) or use the Trim function on each result: ForAll(Split(TextInput1.Text, ","), Trim(Result)).
Another gotcha: empty strings. If your input has consecutive delimiters, like “a,,b”, splitting on “,” gives three rows: a, (empty), b. This can break downstream logic. You can filter out blanks with Filter(Split(...), Result <> "").
Finally, be careful with line breaks. If you split on Char(10) (the line feed character), you might still have carriage returns (Char(13)) left over, especially from Windows text files. Use Split(Text, Char(10)) and then trim each row, or replace Char(13) first.
Choosing the Right Separator
The separator you choose depends on your data. For user-entered lists, a comma is common but risky because users may type commas within an item. A semicolon or pipe (|) is less likely to appear naturally. For example, splitting on a pipe: Split("apples|oranges|bananas", "|").
If you are parsing CSV data, remember that CSV files often use commas as delimiters, but quoted fields can contain commas. The Split function does not handle quoted CSV fields—it will split inside quotes. For robust CSV parsing, consider using a custom function or a data source that handles CSV natively.
When storing the result back to a data source, you might need to rejoin the items with Concat. For example: Concat(Split(TextInput1.Text, ","), Result, "; ") produces a semicolon-separated string.
Split vs. Other Text Functions
Power Apps offers several text functions, and it helps to know when to use which:
Left,Right,Mid: extract fixed-length or position-based substrings. Use when you know the exact character positions.ReplaceandSubstitute: replace text within a string.Substitutereplaces all occurrences;Replacereplaces a specific position.Concat: joins table values into a string—the inverse of Split.MatchandMatchAll: use regular expressions to extract patterns. More powerful but more complex than Split.
For simple delimited lists, Split is the right tool. For extracting substrings based on patterns, consider MatchAll.
Performance and Best Practices
Splitting large strings can impact performance, especially inside galleries or loops. To keep your app responsive:
- Split once and store the result in a variable or collection instead of calling Split repeatedly on the same string.
- Use
SetorCollectto cache the split table if you need to reference it multiple times. - Be mindful of the 2,000-character limit for text strings in Power Apps (though this can vary by data source). Splitting a string near that limit is fine, but processing thousands of rows in a single
ForAllmay be slow.
Example of caching: Set(MyList, Split(TextInput1.Text, ",")) then use MyList in a gallery or ForAll.
Frequently Asked Questions
Can I split on multiple different delimiters at once? No, Split only accepts a single separator string. To split on multiple characters, you can use MatchAll with a regular expression, or replace one delimiter with another before splitting. For example, to split on commas or semicolons, first replace semicolons with commas: Split(Substitute(Text, ";", ","), ",").
How do I get the number of items after splitting? Use CountRows(Split(Text, ",")). This returns the number of rows in the split table, which equals the number of items (including any empty strings).
Why does my split result have an extra blank row at the end? If your original string ends with the delimiter, for example “a,b,”, splitting on “,” gives three rows: a, b, and an empty row. To avoid this, trim the trailing delimiter before splitting: Split(TrimEnds(Text, ","), ",")—though TrimEnds is not a built-in function, so you might use Left(Text, Len(Text)-1) if you know the last character is a delimiter, or use a Filter to remove empty rows.
Can I split a string into characters? Yes, use an empty string as the separator: Split("hello", "") returns a table with each character as a separate row. This is useful for character-by-character processing.
Is Split case-sensitive? Yes, the separator must match exactly, including case. If you need case-insensitive splitting, convert both the text and separator to lower case first: Split(Lower(Text), Lower("AB")).
What is the column name in the result? The result table always has a column named Result. When you reference the split table in a gallery or ForAll, you use ThisItem.Result or Result depending on context.
Related
- Makita BTD144 3-Speed Brushless Impact Driver: Full Review
- Python Update Empty Dictionary: 4 Ways & When to Use Each
- Google Sheets Array Formula: How to Use It
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel WORKDAY Function Examples for Real DeadlinesExcel’s WORKDAY function calculates a date a specified number of working days before or after a starting date,…
- Excel Right-Click Shortcut: Open the Context MenuIn Excel for Microsoft 365 on Windows, select a cell or range and press Shift+F10 to open its…
- SUMIFS in Excel: Multiple Criteria, Examples and TipsYes. In Excel, SUMIFS adds numbers only when multiple conditions are met; each criteria pair can test a…
- Find Names in Excel Using VLOOKUP: Step-by-Step GuideTo find a name and return a related value, put the name you want to search for in…
- IFERROR to Return Zero in Excel: Formula and UsesTo make an Excel formula return zero when it produces an error, wrap it in IFERROR. For example,…
- Excel Trim a Range: Remove Extra Spaces from CellsTo trim a range in Excel, enter =TRIM(A2) beside the first value and fill the formula down; in…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.