The Text.AfterDelimiter function returns everything after a character (or a word) you pick. For example, you can get the domain after the @ in an email address, or the extension after the last dot in a file name.
In this article, I’ll show you how to pick which occurrence of the delimiter to use and how to count from the end of the text. I’ll also cover what you get back when the delimiter isn’t there, which depends on the direction you count.
Follow along with the example file
Text.AfterDelimiter Function Examples.xlsx
Text.AfterDelimiter Function Syntax
Text.AfterDelimiter(text as nullable text, delimiter as text, optional index as any) as any
- text – the text value you want to extract from.
- delimiter – the character (or characters) after which you want the text. It can be a single character like “@” or a longer piece of text like ” to “.
- index (optional) – which occurrence of the delimiter to use. It counts from 0, so 0 is the first one (the default) and 1 is the second. You can also give a list like {0,RelativePosition.FromEnd} to count from the end of the text instead.
What it returns – the text after the chosen delimiter, without the delimiter itself.
The delimiter is case-sensitive, so “Ext.” won’t match “ext.”.
The function also only accepts text. If you point it at a number column, you get a “We cannot convert the value” error, so convert those values with Text.From first.
When to Use the Text.AfterDelimiter Function
Use this function when you need to:
- Get the domain name from email addresses
- Get the file extension from file names, even when the names have more than one dot
- Pull the last part of an address, a category path, or a route
- Remove a prefix (like a channel code) from IDs and keep the number
- Get the text after a label such as “Delayed: ” in status notes
- Strip a brand name from product names when the brand is in another column
Example 1: Get the Text After a Character
Let’s start with a simple one.
Suppose you have a ticket label, “Ticket #4821”, and you want only the ticket number that comes after the # sign.
Create a new blank query (Home > New Source > Blank Query) and use this formula:
= Text.AfterDelimiter("Ticket #4821","#")
Result: 4821

Here, “#” is the delimiter. Text.AfterDelimiter finds the first # in the text and returns everything after it, and the # itself is not part of the result.
Note that the result is the text “4821”, not a number. If you need it as a number, wrap the formula in Number.From.
Example 2: Get the Domain From Email Addresses
This one comes up a lot when you work with customer or signup lists.
Below is a Customers table with each customer’s name and email address, and I want the domain (everything after the @) in a new Domain column.

To follow along, select any cell in the Customers 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,"Domain",each Text.AfterDelimiter([Email],"@"),type text)
Result: A new Domain column with lakeside.com, greenfield.co.uk, gmail.com, mapleridge.org, and summitbay.net.

In the above formula, Table.AddColumn adds a new column called Domain. For each row, Text.AfterDelimiter looks at the Email value and returns everything after the “@”.
Here, each tells Power Query to run the formula once for every row, and [Email] is the value in the Email column of that row. The last argument, type text, sets the data type of the new column to text.
Since the function returns everything after the delimiter, you get the full domain, including longer endings like “.co.uk”.
Example 3: Use a Word as the Delimiter
The delimiter doesn’t have to be a single character. It can be a whole word.
Below is a Routes table where each route is written as “City to City”, and I want the destination city in a new Destination column.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"Destination",each Text.AfterDelimiter([Route]," to "),type text)
Result: A new Destination column with Ottawa, Kansas City, Salt Lake City, St. Louis, and Santa Fe.

Here, the delimiter is ” to “, with a space on both sides. That’s important, because the city “Toronto” ends with the letters “to”.
Without the spaces, the delimiter “to” would match the end of “Toronto” first, and you’d get ” to Ottawa” for that row. With the spaces, it only matches the word “to” between the two cities, and the result doesn’t start with a space either.
Example 4: Get the Text After the Second Comma
By default, Text.AfterDelimiter uses the first occurrence of the delimiter. The third argument lets you pick a later one.
Below is an Addresses table where each address has the street, the city, and then the state and ZIP code, all separated by commas, and I want the state and ZIP code in a new State and ZIP column.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"State and ZIP",each Text.AfterDelimiter([Address],", ",1),type text)
Result: A new State and ZIP column with OH 45402, TX 78701, CA 93721, FL 33602, and ID 83702.

The 1 in the third argument tells Power Query to use the second “, ” in the text. The count starts at 0, so 0 is the first comma (the default) and 1 is the second.
If you used the formula without the 1, you’d get the city along with the state and ZIP (like “Dayton, OH 45402”), because that’s everything after the first comma.
This works because every address here has exactly two commas before the state. If some addresses have an extra part, like “12 Oak St, Apt 4, Dayton, OH 45402”, use {0,RelativePosition.FromEnd} instead (covered in the next example) to get the text after the last comma.
Example 5: Get the File Extension From File Names
This is where counting from the end of the text really helps.
Below is a Downloads table with file names and their sizes, and some file names have more than one dot, and I want the file extension in a new Extension column.

If you use Text.AfterDelimiter([File Name],”.”) here, you get everything after the first dot. So “Budget.v2.final.xlsx” gives you “v2.final.xlsx”, which is not the extension.
What you want is the text after the last dot. To get that, add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"Extension",each Text.AfterDelimiter([File Name],".",{0,RelativePosition.FromEnd}),type text)
Result: A new Extension column with xlsx, jpg, pdf, csv, and txt.

Here, {0,RelativePosition.FromEnd} tells Power Query to count the dots from the end of the text, and 0 means the last one. So you always get the text after the last dot, no matter how many dots the file name has.
Follow along with the example file
Text.AfterDelimiter Function Examples.xlsx
Example 6: Get the Last Two Levels of a Category Path
You can also count back further than the last delimiter.
Below is a Catalog table where each item has a category path like “Home > Kitchen > Cookware > Pans”, with a different number of levels for different items, and I want the last two levels in a new Subcategory column.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"Subcategory",each Text.AfterDelimiter([Category Path]," > ",{1,RelativePosition.FromEnd}),type text)
Result: A new Subcategory column with Cookware > Pans, Cycling > Helmets, Notebooks > Spiral, Tools > Pruners, and Games > Puzzles.

Here, {1,RelativePosition.FromEnd} picks the second-to-last ” > ” in the path. Everything after it is the last two levels, and the ” > ” between them stays in the result.
Counting from the start wouldn’t work here, because the paths have three or four levels. Counting from the end gives you the right part in every row.
Example 7: When the Delimiter Is Missing
Not every row will have the delimiter, and it helps to know what you get back.
Below is a Deliveries table with a status note for each order, where some notes have a reason after a colon (like “Delayed: Weather”) and some don’t, and I want the reason in a new Reason column.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"Reason",each Text.AfterDelimiter([Status Note],": "),type text)
Result: Weather, Customs check, and Wrong address for the notes with a colon, and an empty value for Delivered and In Transit.

When the delimiter isn’t in the text, Text.AfterDelimiter doesn’t give an error. It returns an empty text (“”), which looks like a blank cell in the preview.
An empty text is not the same as null, though. A filter on null, or a count of non-null values, won’t treat these rows as missing.
The same happens if you ask for an occurrence that doesn’t exist, like the third “: ” in a note that has only one. Blank cells (null) in the Status Note column also give you an empty text.
If you’d rather get null for the rows without a reason, replace the formula in the step you just added with this one:
= Table.AddColumn(Source,"Reason",each
let reason = Text.AfterDelimiter([Status Note],": ")
in if reason = "" then null else reason,type text)
Result: Weather, Customs check, and Wrong address as before, and null for Delivered and In Transit.

Here, let reason = ... stores the extracted text under the name reason, so the formula doesn’t have to run Text.AfterDelimiter twice. If reason is an empty text, the formula returns null, and otherwise it returns the reason.
This also works if your own data has blank cells in the Status Note column, since a null note gives an empty text, which then becomes null.
If you check the note first with Text.Contains, it returns null for a blank note. An if condition needs true or false, so a bare if Text.Contains([Status Note],": ") then errors on that row.
Example 8: Counting From the End Returns the Original Text
This next one is easy to miss. When you count from the end and the delimiter isn’t there, you don’t get an empty text, you get the whole original text back.
Below is a SharedFiles table with file names and their owners, where two of the files (README and LICENSE) have no extension at all, and I want the extension in a new Extension column.

Add a new step (by clicking on the fx icon next to the formula bar) and use the same formula as in Example 5:
= Table.AddColumn(Source,"Extension",each Text.AfterDelimiter([File Name],".",{0,RelativePosition.FromEnd}),type text)
Result: pdf, png, and docx for the files with an extension, but README and LICENSE for the two files without one.

Since README has no dot, Text.AfterDelimiter can’t find a last dot, so it returns the whole file name. That looks like an extension in the Extension column, and it’s easy to miss in a long list.
So the result depends on the direction. Counting from the start (as in Example 7), a missing delimiter gives you an empty text, but counting from the end gives you the original text.
If you’ve used Text.BeforeDelimiter, it works the other way around. When the delimiter is missing, it returns the whole text counting from the start, and an empty text counting from the end.
To get null for the files without an extension, replace the formula in the step you just added with this one:
= Table.AddColumn(Source,"Extension",each
let ext = Text.AfterDelimiter([File Name],".",{0,RelativePosition.FromEnd})
in if ext = [File Name] then null else ext,type text)
Result: pdf, png, and docx as before, and null for README and LICENSE.

Here, ext holds the result of Text.AfterDelimiter, and when the file name has a dot, ext is shorter than the file name. So if ext is exactly the same as the file name, there was no dot, and the formula returns null instead.
One thing this formula doesn’t catch is a blank cell. A null file name gives you an empty text (not null), even when counting from the end, so it stays as an empty value in the Extension column.
Example 9: Remove a Prefix From a Column in Place
In all the examples so far, the result went into a new column. Sometimes you want to clean the column itself instead.
Below is an Orders table where each order reference starts with the sales channel (like WEB- or STORE-), and I want to remove the channel and keep only the order number in the same Order Ref column.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.TransformColumns(Source,{{"Order Ref",each Text.AfterDelimiter(_,"-"),type text}})
Result: The Order Ref column now shows 10482, 10483, 10484, 10485, and 10486.

Here, Table.TransformColumns changes the values of the Order Ref column instead of adding a new one. Inside it, _ stands for the current value in that column, so Text.AfterDelimiter(_,”-“) returns the part after the hyphen.
Be careful with this one, because it replaces the original values. If an order reference has no hyphen (say “10487”), it becomes an empty text, and the reference is lost from that column.
Example 10: Use Another Column as the Delimiter
The delimiter doesn’t have to be fixed text. It can come from another column in the same row.
Below is a Products table where each product name starts with its brand, and the brand is also in its own Brand column, and I want the product name without the brand in a new Product Name column.

Using a space as the delimiter won’t work here, because “North Peak” has a space inside the brand name. So you’d get “Peak Rain Jacket” for that row.
Instead, add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"Product Name",each Text.AfterDelimiter([Product],[Brand] & " "),type text)
Result: A new Product Name column with Desk Lamp, Bookshelf, Rain Jacket, Floor Lamp, and Water Bottle.

Here, [Brand] & ” ” joins the brand name and a space, so the delimiter for the first row is “Brightway ” and for the third row is “North Peak “. Text.AfterDelimiter then returns everything after the brand and its space.
Since the delimiter changes from row to row, the formula works no matter how many words the brand name has.
Make sure the Brand column has no blank cells, though. A null brand makes the delimiter null, and that row shows an Error (“We cannot convert the value null to type Text”).
Other Excel Articles You May Also Like:
- Text.BetweenDelimiters Function in Power Query M
- Text.PositionOf function
- Text.Split – Use Text.Split in Power Query M to split text into a list.
- Splitter.SplitTextByDelimiter – Use Splitter.SplitTextByDelimiter in Power Query M to split text.
- Text.Start – Use Text.Start in Power Query M to grab the first few characters from a text value.
- Text.TrimEnd – Use Text.TrimEnd in Power Query M to remove trailing spaces or characters.
- Text.Replace – Use Text.Replace in Power Query M to replace text in a string.
- Text.StartsWith – Use Text.StartsWith in Power Query M to check whether text begins with a prefix.