Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Splitter.SplitTextByCharacterTransition in Power Query

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The Splitter.SplitTextByCharacterTransition function in Power Query returns a splitter function that breaks a text value wherever the character type changes. You use it inside Table.SplitColumn or Text.Split to cut strings like "ABC123def" into runs of letters and runs of digits. Nothing needs to be installed first: the function is built into the Power Query engine in Excel, Power BI Desktop and Power Query in Fabric or SharePoint when the source is Excel or CSV data loaded through Power Query. It is not available in Power Query Online when the query uses a connector that restricts the M engine, such as some web and database connectors run through the gateway, so build the query against a local file when testing.

What You'll Need

  • Power Query Editor open in Excel, Power BI Desktop, or Power Query from the Data tab. Menu and command names differ slightly by version, host application and region, but the Editor layout is broadly the same.
  • A text column that mixes different types of characters, such as letter-digit pairs ("Item42"), letter-symbol pairs, or words separated by mixed punctuation.
  • Basic familiarity with the formula bar and the Advanced Editor, because this function is written in M code rather than clicked together from a dialog.
  • A clear idea of what counts as a break: a change from letter to digit, digit to letter, or a change involving a specific set of characters you name.

Step-by-Step

  1. Load your data into Power Query. Select your table and choose Data > From Table/Range, or use Get Data to pull in the source. In the Editor, confirm the column you want to split actually contains text: check the icon in the column header (it should read ABC), not a number or date type.
  2. Understand the signature. The function takes one argument: a list of two characters, lists of characters, or lists of lists of characters. Each pair describes a transition. For example, {"0".."9", "A".."Z"} says: split where a digit is followed by an uppercase letter, or where an uppercase letter is followed by a digit. The result is a splitter function, not the split text itself.
  3. Decide which transitions you need. If you want to break "Total99Units" into "Total", "99" and "Units", you need letter-to-digit and digit-to-letter transitions. If you also want to split on spaces or punctuation, add those characters into the lists. Character ranges in M use the range operator, so {"a".."z"} is all lowercase letters and {"0".."9"} all digits.
  4. Add a custom step using Table.SplitColumn. With the column selected, open Home > Advanced Editor and add a step after the previous one. Name the column and pass the splitter function. A typical step looks like this: SplitLettersAndDigits = Table.SplitColumn(PreviousStep, "Text", Splitter.SplitTextByCharacterTransition({"A".."Z"}, {"0".."9"}), {"Text.1", "Text.2"})
  5. Give each split column a name. The fourth argument is a list of new column names. It must match the number of pieces produced. If your strings can produce more than two runs ("A1B2" produces four), either list enough names or omit the name list so the function generates numbered names automatically, then rename afterward.
  6. Press Done and inspect the result. If a name count mismatch exists, Power Query reports an error rather than guessing. Read the error text carefully: it usually names the expected and returned counts. Look at a few rows to confirm the split happened exactly where you expected.
  7. Handle runs of mixed case and symbols carefully. Uppercase and lowercase letters are different character ranges. To treat them as one group, list both ranges in the same side of the pair: Splitter.SplitTextByCharacterTransition({"a".."z", "A".."Z"}, {"0".."9"}). The same applies to accented letters, which fall outside the basic A-Z range and will split unexpectedly unless added.
  8. Test with a small sample query. Before applying the step to a large table, create a single-column query with a handful of hard typed values such as in the Advanced Editor, then run the same splitter on it. Because the splitter is just a function, you can write Splitter.SplitTextByCharacterTransition({"A".."Z"}, {"0".."9"})("ABC123") directly to see the resulting list.
  9. Apply to the real column. Once the switch pattern works, copy the exact splitter expression into your main query's Table.SplitColumn step, close Apply and load or close the query as you normally would.

Common Mistakes

Treating the function as a splitter that returns text. It returns a function that splits text. Calling it without the second set of parentheses gives you a function value, and Table.SplitColumn then fails to use it correctly.

Listing only one direction of the transition. Passing only letter-to-digit means "ABC123" splits but "123ABC" does not. Most real data needs both directions, so build the pairs in both orders.

Forgetting case and accented characters. A single {"A".."Z"} range misses lowercase letters, so "abc123" stays whole. This is the most frequent cause of partial splits.

Too few column names. The name list length must match the pieces the function generates. Guessing the count is the second most frequent error; omit the names and rename later if the count is variable.

Assuming every row splits the same number of times. Character transitions are content dependent, so a row with no transitions returns the original text in the first column and nulls in the rest. Plan for nulls.

Tips

Keep a scratch query with sample strings for testing. Because the splitter is a plain function, you can call it anywhere a text list is expected, including inside Text.Split on a single value. Use the Advanced Editor to comment out alternative splitters rather than deleting them, which makes comparing behaviour faster. When a column has both spaces and transitions, consider splitting on the transition first and then trimming the pieces. If your data is consistently structured, a fixed-length splitter such as Splitter.SplitTextByPositions is simpler and less error-prone. Finally, check the query steps pane: each split appears as its own step, so you can delete and redo one without rebuilding the rest.

Troubleshooting

If nothing splits, confirm the column type is Text. A column typed as Number cannot be split as text and the step will error or return nulls. If you see an error about the number of names, count the maximum pieces your data can produce and add names accordingly. If splitting happens in unexpected places, print the ranges you supplied in a small test query: a range written with a wrong order, such as {"Z".."A"}, gives an empty list and therefore never matches. If the result has more columns than expected, inspect the sample rows with the most transitions; the splitter creates as many columns as the widest row needs. If your query fails only when refreshed in the service, the M engine there may restrict the function; rebuild the step in Power BI Desktop against a local file and republish.

Frequently Asked Questions

Does this function change the column type?

No. It only splits text. The new columns are text values and need to be retyped manually if any piece is numeric or a date.

Can it split on changes between letters and punctuation?

Yes. Put the punctuation characters in the second list, so letter-to-punctuation and punctuation-to-letter both break.

Is it available in Power Query Online?

It depends on the connector. Connectors that restrict the engine may reject it; local file and Excel sources generally support it.

What happens to rows with no transition?

They stay in the first output column, and the remaining named columns receive null.

Can I combine several transitions in one call?

Yes. Each pair in the list is checked, so listing several pairs covers letter-to-digit, digit-to-letter and symbol-to-letter in one splitter.