Power Query CombineTextByEachDelimiter: How to Use
In this article
The Combiner.CombineTextByEachDelimiter function in Power Query returns a combiner function that joins a list of text values using a different delimiter between each pair of items. You supply an ordered list of delimiters, and the function inserts the first delimiter between item 1 and item 2, the second between item 2 and item 3, and so on. If there are more items than delimiters, the last delimiter is repeated for any remaining gaps. To use it, you call the function with your delimiter list, then pass the resulting combiner to a function that accepts a combiner, such as Text.Combine or List.Accumulate in a custom column or advanced editor step. Nothing needs to be installed beyond Power Query, which is built into Excel, Power BI, and Power Query Online.
What You'll Need
- Access to Power Query: Excel (Data > Get Data), Power BI Desktop (Transform Data), or Power Query Online.
- A table or list of text values you want to join, loaded into the Power Query Editor.
- Basic familiarity with the Advanced Editor or the formula bar, since this function is not exposed as a button in the ribbon.
- A clear idea of the exact delimiter order you need (for example, a comma then a space, or a slash then a dash).
Step-by-Step
- Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI Desktop, use Home > Transform Data to open the Power Query Editor. In Power Query Online, open your dataflow or query and select the query you want to edit.
- Decide where the combined text should appear. You can add a custom column (Add Column > Custom Column) or create a new query step. The function works on a list, so you will typically use it inside a custom column formula where each row supplies its own list of text values.
- Write the combiner call. The syntax is
Combiner.CombineTextByEachDelimiter(delimiters as list, optional quoteStyle as nullable number) as function. For example,Combiner.CombineTextByEachDelimiter({", ", " - "})creates a combiner that puts a comma and space between the first two items and a space-dash-space between the next two. The optionalquoteStyleargument controls how embedded quotes are handled; leave it out unless you specifically need to change quoting behavior. - Pass the combiner to Text.Combine. In a custom column formula, use something like
Text.Combine({[FirstName], [LastName], [Nickname]}, Combiner.CombineTextByEachDelimiter({" ", " ("})). This joins the three fields with a space between the first two and a space-parenthesis between the second and third. Note thatText.Combineaccepts a combiner function as its second argument in Power Query M. - Handle nulls and empty values.
Text.Combineignores null values by default, but the delimiter positions are still consumed based on the original list order. If you need to skip empty strings as well, filter them out first withList.SelectorList.RemoveItemsbefore combining. - Test with a small sample. Create a custom column with your formula and inspect the output for a few rows. Check that the delimiters appear in the right places and that no extra delimiters appear at the start or end. The function does not add a delimiter before the first item or after the last item.
- Apply and load. Once the formula works, close and load the query to your worksheet or data model. If you used a custom column, it will appear as a new column in the output table.
Common Mistakes
- Passing a single text value instead of a list. The first argument must be a list, so use curly braces:
{", "}, not", ". A plain text value will cause an error. - Expecting the delimiter list to cycle. The function does not repeat the list from the beginning; it repeats only the last delimiter once the list is exhausted. If you need a repeating pattern, build a longer delimiter list or use a different approach.
- Forgetting that nulls consume a delimiter slot. If your list contains nulls, the delimiter for that position is still used up, which can shift where later delimiters appear. Clean nulls first if the order matters.
- Using the wrong function name. The correct name is
Combiner.CombineTextByEachDelimiter, notCombiner.CombineTextByDelimiter(which uses one delimiter for all gaps). Check spelling and capitalization. - Assuming it works in the ribbon. This function is only available through the M formula language, so you must type it in the formula bar or Advanced Editor. It will not appear in the Custom Column dialog's list of functions.
Tips
- Use the formula bar to experiment: select a step, then edit the formula directly and press Enter to see the result immediately.
- If you need a delimiter only between some items, consider building the list conditionally with
List.TransformorList.Accumulateinstead of relying on positional delimiters. - Keep delimiter lists short and explicit. A list like
{", ", "; ", " | "}is easier to debug than a long, repetitive list. - Remember that
Text.Combineconverts non-text values to text automatically, but it is safer to convert numbers and dates explicitly withText.Fromfirst. - Document your formula with a comment (using
//) in the Advanced Editor so future you remembers why the delimiter order matters.
Troubleshooting
If you get an error saying the argument is not a list, check that your delimiter argument is wrapped in curly braces. If the output has delimiters in unexpected places, print the input list length and the delimiter list length to confirm they match your expectation. If Text.Combine throws an error about the combiner, make sure you are passing the function itself, not the result of calling it with a list of text values. If nulls are causing shifts, add a step to replace nulls with empty text or filter them out before combining. If the function name is not recognized, verify that you are in the Power Query M editor and not in a DAX formula bar; this function does not exist in DAX.
Frequently Asked Questions
What is the difference between CombineTextByEachDelimiter and CombineTextByDelimiter?
CombineTextByDelimiter uses the same delimiter between every pair of items. CombineTextByEachDelimiter lets you specify a different delimiter for each gap, in order.
Can I use this function in a calculated column in Power BI?
No, it is a Power Query M function. You can use it in the Power Query Editor to shape data before loading, but not in DAX calculated columns or measures.
What happens if I provide more delimiters than there are gaps?
Extra delimiters are ignored. Only the delimiters needed for the number of items minus one are used.
Does the function add a delimiter at the beginning or end?
No. Delimiters are only inserted between items, never before the first or after the last.
How do I handle null values when using this combiner?
Text.Combine skips null values, but the delimiter position for that null is still consumed. To avoid unexpected delimiter placement, remove or replace nulls before combining.
Is this function available in Excel Power Query?
Yes, it is part of the standard Power Query M library in Excel, Power BI, and Power Query Online. The exact menu labels for opening the editor can differ slightly by version and platform.