Text.Split Function in Power Query M

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

The Text.Split function in Power Query breaks a text value into pieces wherever a delimiter appears, like a comma, a hyphen, or a slash. You get the pieces back as a list.

In this article, I’ll show you how to use it, how to pick one piece from the list, and how to turn a cell with several values into separate rows.

Follow along with the example file

Text.Split Function Examples.xlsx

Download

Text.Split Function Syntax

Text.Split(text as text, separator as text) as list
  • text – the text value you want to split.
  • separator – the delimiter to split at. It can be a single character, like a comma, or a sequence of characters, like ” > “. With a sequence, the text is split only where that exact sequence appears.

What it returns: A list of text values. The delimiter itself isn’t part of any item.

The separator is case-sensitive, so ” and ” won’t split at ” AND “. If the separator isn’t in the text at all, you don’t get an error, just a list with one item: the whole text.

Text.Split only accepts text. A null or a number gives you a “We cannot convert the value” error, so convert numbers with Text.From first.

The Text.Split function is part of the core Power Query M library, so it works wherever Power Query does, including Excel for Microsoft 365, 2024, 2021, 2019, and 2016 (on Windows for 2019 and 2016), and Power BI.

When to Use the Text.Split Function

Use this function when you need to:

  • Turn a comma-separated text value into a list
  • Get one part of a code or ID, like the year in “NYC-2026-014”
  • Get the last part of a path, like the file name
  • Count how many items a cell holds, like skills or tags
  • Put each value from a cell like “Isaac, Tyler, Carmen” on its own row
  • Clean up or reorder the parts of a text value and join them back together

If you only need the text before or after one delimiter, the Text.BeforeDelimiter and Text.AfterDelimiter functions get it in one step. Text.Split is the better choice when you need several pieces, the last piece, or a count.

Example 1: Split a Comma-Separated Text Into a List

Let’s start with the basics. Suppose you have the text “Laptop,Monitor,Keyboard,Mouse” and you want each item on its own.

In Excel, go to Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor that opens, type this formula in the formula bar:

= Text.Split("Laptop,Monitor,Keyboard,Mouse",",")

Result: Laptop, Monitor, Keyboard, Mouse

Text.Split on "Laptop,Monitor,Keyboard,Mouse" with "," returns a list of four items

Here, “,” is the separator. Text.Split cuts the text at every comma and returns the four pieces as a list, which the Power Query Editor shows with one item per row.

If you want this list as a table, click To Table on the List Tools tab. Power Query writes a Table.FromList step for you.

Examples 1 and 2 type their text right into the query, so they don’t need a table on a worksheet. In the example file, you can open them from Data > Queries & Connections.

Example 2: Use More Than One Character as the Separator

The separator doesn’t have to be a single character.

Suppose you have a category path like “Home > Kitchen > Cookware > Pans”, where the levels are separated by a space, a greater-than sign, and another space.

Create a new blank query (as in Example 1) and use this formula:

= Text.Split("Home > Kitchen > Cookware > Pans"," > ")

Result: Home, Kitchen, Cookware, Pans

Text.Split with the " > " separator returns Home, Kitchen, Cookware, Pans

Here, the separator is ” > “, with a space on each side. Because the spaces are part of the separator, they’re removed along with the greater-than sign, and each item comes out clean.

If you split at “>” alone, you’d get items like “Home ” and ” Kitchen ” with extra spaces at the ends.

Example 3: Get One Part by Its Position

Text.Split gives you a list, but often you only want one item from it. You can pick an item by its position.

Below is a Projects table with project codes like NYC-2026-014, where the middle part is the year, and I want that year in a new Year column.

Projects table with project codes like NYC-2026-014 and a Status column

To follow along, select any cell in the Projects table and go to Data > From Table/Range. This opens the table in the Power Query Editor, where the Source step holds it (if Power Query adds a Changed Type step too, you can delete it).

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(Source,"Year",each Text.Split([Project Code],"-"){1},type text)

Result: A new Year column with 2026, 2025, 2026, 2024, and 2026.

New Year column with the second part of each project code

In the above formula, Table.AddColumn adds a new column called Year. For each row, Text.Split breaks the project code at every hyphen, so “NYC-2026-014” becomes the list NYC, 2026, 014.

The {1} after it picks an item from that list. Positions start at 0, so {0} is the first item (NYC) and {1} is the second (2026).

Here, each tells Power Query to run the formula once for every row, and [Project Code] is the value in the Project Code column of that row. The last argument, type text, sets the new column’s data type to text.

If a code has fewer parts than the position you ask for, you get an error in that row. Adding a question mark, like {1}?, returns null instead of the error.

Example 4: Get the Last Part of a Path

Sometimes the part you want is the last one, and the number of parts before it changes from row to row.

Below is a Files table with file paths like Reports/2026/Q1/summary.pdf, where some paths have more folders than others, and I want just the file name in a new File Name column.

Files table with file paths of different depths

A fixed position won’t work here, because the file name is the fourth item in one path and the second in another.

Load the Files table into Power Query (select any cell in it and go to Data > From Table/Range, as in Example 3). Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(Source,"File Name",each List.Last(Text.Split([Path],"/")),type text)

Result: A new File Name column with summary.pdf, march-invoice.xlsx, leave-policy.docx, notes.txt, and banner.png.

New File Name column with the last part of each path

Here, Text.Split breaks each path at every slash, and the List.Last function returns the last item of that list. That’s always the file name, no matter how many folders come before it.

The path notes.txt has no slash at all. Text.Split returns it as a one-item list, so List.Last gives you notes.txt unchanged instead of an error.

Example 5: Count the Items in a Cell

Since Text.Split returns a list, you can count the items in it. That tells you how many values a cell holds.

Below is an Employees table with each employee’s skills in one cell, separated by a comma and a space, and I want the number of skills in a new Skill Count column.

Employees table with comma-separated skills in one cell

Load the Employees table into Power Query (select any cell in it and go to Data > From Table/Range, as in Example 3). Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(Source,"Skill Count",each List.Count(Text.Split([Skills],", ")),Int64.Type)

Result: A new Skill Count column with 3, 1, 2, 4, and 2.

New Skill Count column: 3, 1, 2, 4, 2

Here, Text.Split turns “Excel, SQL, Power BI” into a list of three skills, and List.Count counts them. Int64.Type sets the new column as a whole number column.

Zoe Patterson’s cell has just one skill and no separator, so Text.Split returns a one-item list and the count is 1.

Follow along with the example file

Text.Split Function Examples.xlsx

Download

Example 6: Split Values Into Separate Rows

This is one of the most common reasons people look for Text.Split. One cell holds several values, and you want each value on its own row.

Below is a Workshops table where each workshop lists its attendees in one cell, like “Isaac, Tyler, Carmen”, and I want one row per attendee in the Attendees column.

Workshops table with several attendees in one cell

First, load the Workshops table into Power Query (Data > From Table/Range, as in Example 3). Splitting it into rows then takes two steps.

For the first one, add a new step (by clicking on the fx icon next to the formula bar) and use this formula to turn each Attendees cell into a list:

= Table.TransformColumns(Source,{{"Attendees",each Text.Split(_,", ")}})

Result: Each cell in the Attendees column now shows List.

After Text.Split, each Attendees cell holds a List

Here, Table.TransformColumns changes the values in the Attendees column instead of adding a new one. The _ stands for the current value in that column, so Text.Split runs once on each cell.

Each cell now holds a list of names. If you click the empty space next to List in a cell, you can see that row’s names at the bottom of the editor.

The next formula refers to this step by its name. In the example file, it’s named Split Attendees, but a step you add with the fx icon is named Custom1 by default, so rename your step or use Custom1 in the formula.

Now add one more step and use this formula to put each name on its own row:

= Table.ExpandListColumn(#"Split Attendees","Attendees")

Result: Eight rows, one per attendee, with the workshop name repeated on each row.

Table.ExpandListColumn puts each attendee on its own row

The Table.ExpandListColumn function takes the lists in the Attendees column and gives each item its own row. The other columns are copied down, so the Pivot Tables workshop now appears on three rows, one for each of its attendees.

If you’d rather not write the formulas, Home > Split Column > By Delimiter can also split into rows (it’s under Advanced options). The same command splits into separate columns instead, if that’s what you need.

Example 7: Skip the Empty Items

When a text value has two delimiters in a row, or a delimiter at the very start or end, Text.Split doesn’t skip it. It returns an empty item for each of those spots.

Below is a Tickets table with the tags on each support ticket, where some cells have an extra comma (like “billing,refund,”), and I want the number of real tags in a new Tag Count column.

Tickets table where some Tags cells have extra commas

If you count the items right after Text.Split, “billing,refund,” gives you 3, because the comma at the end creates an empty third item. So you need to remove the empty items first.

Load the Tickets table into Power Query (select any cell in it and go to Data > From Table/Range, as in Example 3). Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(Source,"Tag Count",each List.Count(List.Select(Text.Split([Tags],","),each _<>"")),Int64.Type)

Result: A new Tag Count column with 2, 2, 1, 2, and 2.

New Tag Count column that ignores the empty items: 2, 2, 1, 2, 2

Here, Text.Split turns “login,,password” into three items: login, an empty item, and password. List.Select then keeps only the items that aren’t empty, and List.Count counts what’s left.

Inside List.Select, each _<>"" is the test for every item. The _ stands for one item of the list, and <>"" means “is not empty text”, so the empty items are dropped.

You can also drop the empty items with List.RemoveItems(Text.Split([Tags],","),{""}), which removes every item that matches “”. It gives the same count, so use whichever reads easier to you.

Example 8: Clean Up Uneven Spaces Around the Delimiter

Data typed by hand often has spaces in random places around the commas. That makes a separator like “, ” unreliable.

Below is a Customers table with each customer’s preferred contact channels, where the spacing around the commas is different in every cell (like “Chat , Email”), and I want a clean list in a new Clean Channels column.

Customers table with uneven spaces around the commas in Channels

Some of these spaces are hard to spot. C-204 starts with a space before Email, and C-205 has a space before the comma instead of after it.

If you split “Chat ,Phone” at “, “, there’s no match, so you get the whole text back as one item. Splitting at “,” alone works, but then items like “Chat ” keep their extra spaces.

Load the Customers table into Power Query (select any cell in it and go to Data > From Table/Range, as in Example 3). Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(Source,"Clean Channels",
each Text.Combine(List.Transform(Text.Split([Channels],","),Text.Trim),", "),type text)

Result: A new Clean Channels column where every cell uses a comma and one space, like “Chat, Email” and “Phone, Chat, Email”.

New Clean Channels column with one comma and one space between channels

Here, Text.Split breaks each cell at every comma, whatever the spacing. List.Transform then runs the Text.Trim function on every item, which removes the spaces at the start and end.

Finally, Text.Combine joins the clean items back together with a comma and a single space. Now every cell follows the same pattern, so a later split at “, ” works on all of them.

Example 9: Flip “Last, First” Names

You can also split a value, change the order of the pieces, and join them back.

Below is a Contacts table where each name is stored as “Last, First” (like “Phillips, Susan”), and I want the name as “First Last” in a new Full Name column.

Contacts table with names stored as Last, First

Load the Contacts table into Power Query (select any cell in it and go to Data > From Table/Range, as in Example 3). Then add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(Source,"Full Name",each Text.Combine(List.Reverse(Text.Split([Contact],", "))," "),type text)

Result: A new Full Name column with Susan Phillips, Allison Cooper, Rhonda Shaw, Edward Reed, and Ricky Perry.

New Full Name column with each name as First Last

Here, Text.Split turns “Phillips, Susan” into the list Phillips, Susan. The List.Reverse function flips it to Susan, Phillips, and Text.Combine joins the two items with a space.

The separator “, ” includes the space after the comma, so neither name ends up with an extra space. This works because every name has exactly one comma, so the list always has two items.

Other Excel Articles You May Also Like:

All Power Query Functions

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.