Smart Systems for Home

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

Power Query CombineTextByDelimiter: How to Use It

· 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

CombineTextByDelimiter is a Power Query M function that joins a list of text values into a single string, inserting a delimiter of your choice between each item. It solves the common problem of turning a column of values into one comma-separated string, a pipe-separated string, or any custom-separated list, without writing manual concatenation formulas. You need Power Query available (Excel, Power BI, or another host) and a table or list to work with. The steps below use Excel's Power Query Editor, but the M code is identical in Power BI Desktop; menu labels can differ slightly by version and region.

What You'll Need

  • A table loaded into Power Query (select your data and use Data > From Table/Range in Excel, or Get Data in Power BI).
  • Basic familiarity with the Power Query Editor and the formula bar.
  • Optionally, the Advanced Editor for writing M directly (Home > Advanced Editor).
  • Your chosen delimiter, such as a comma, semicolon, pipe, or line break.

Step-by-Step

  1. Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI, use Home > Get Data and pick your source. Confirm the data appears in the Power Query Editor.
  2. Decide the shape of the input. CombineTextByDelimiter expects a list of text values, not a whole table. You will typically build that list from a column. If you want to combine values from multiple columns in one row, you can reference those fields directly in a list.
  3. Create a list from a column. Select the column you want to combine. On the Transform tab, use the option to convert the column to a list (in many versions this is Transform > To List, or you can write Table.Column(YourTable, "ColumnName") in a custom step). This produces a list value.
  4. Add a custom step. Go to Home > Advanced Editor or Add Column > Custom Column. In the formula box, enter the function call. The syntax is Combiner.CombineTextByDelimiter(delimiter, optional quoteStyle), which returns a function that takes a list. A complete example: Combiner.CombineTextByDelimiter(",", QuoteStyle.None)({"A", "B", "C"}) returns A,B,C.
  5. Apply it to your list. Replace the literal list with your column reference. For example, if your list step is named ColumnList, write Combiner.CombineTextByDelimiter(",", QuoteStyle.None)(ColumnList). The result is a single text value.
  6. Handle quoting if needed. The second argument controls how values containing the delimiter are quoted. QuoteStyle.None inserts no quotes. QuoteStyle.Csv wraps values that contain the delimiter or quotes in double quotes and escapes inner quotes, which is what you want if the output will be parsed as CSV. Choose based on how the result will be used.
  7. Check the output. The result is one text string. If you are combining a whole column, you will get one long string for the entire column, not one per row. To combine values per row, group your data first (Transform > Group By) and then apply the combiner to the grouped list.
  8. Load the result. Use Home > Close & Load (Excel) or Home > Close & Apply (Power BI) to bring the query back into your workbook or model.

Common Mistakes

  • Passing a table instead of a list. CombineTextByDelimiter works on a list. If you pass a table, you get an error. Convert the column to a list first with Table.Column or the To List transform.
  • Forgetting the second function call. The function is curried: Combiner.CombineTextByDelimiter(",") returns a function, not a string. You must call it again with the list, as in ...(list).
  • Using the wrong delimiter type. The delimiter must be text. Passing a number or a null causes an error. Wrap special characters in quotes.
  • Expecting row-level results from a column-level list. Combining a whole column produces one string. If you need one string per row, group by the row identifier first.
  • Ignoring nulls. Null values in the list are treated as empty text by default, which can produce doubled delimiters. Clean nulls with Table.SelectRows or List.Select before combining if that matters.
  • Quoting surprises. With QuoteStyle.Csv, values containing the delimiter get quoted. If you did not expect quotes in the output, switch to QuoteStyle.None, but only if the data does not contain the delimiter.

Tips

  • Use a delimiter that does not appear in your data (for example a pipe or tab) to avoid ambiguous output.
  • Name your steps clearly, such as ListForCombine, so the final formula is readable.
  • For CSV-style output, use QuoteStyle.Csv and test with a value that contains a comma and a quote.
  • To combine values from several columns in the same row, build a list literal like {[First], [Last]} and pass it to the combiner.
  • Use the formula bar to inspect the generated M code; it is often easier to edit there than in the Advanced Editor.
  • If you need a line break as the delimiter, use "#(lf)" in M.

Troubleshooting

If you see an error saying a list was expected, check that your input is a list value, not a table or a single text. Use Table.Column to extract the column as a list. If the output contains doubled delimiters, your list likely contains nulls or empty strings; filter them out with List.Select(list, each _ <> null and _ <> "") before combining. If quotes appear unexpectedly, review the QuoteStyle argument. If the result is one long string when you wanted one per row, you applied the function to a whole column; group by your row key first. If the function name is not recognized, confirm you are using the full name Combiner.CombineTextByDelimiter (not just CombineTextByDelimiter) and that your host supports it; it is part of the standard M library in Excel and Power BI. If the query is slow on a very large list, consider filtering rows before converting to a list.

Frequently Asked Questions

What is the difference between CombineTextByDelimiter and Text.Combine?

Text.Combine joins a list with a delimiter in one call. CombineTextByDelimiter returns a function that can be reused, and it adds quote handling via QuoteStyle. For simple joins, Text.Combine is shorter; for CSV-safe output, use the combiner.

Can I combine values from multiple columns in one row?

Yes. Build a list literal such as {[Column1], [Column2]} and pass it to the combiner function. The result is a single string for that row.

How do I combine a whole column into one string?

Convert the column to a list with Table.Column, then call the combiner on that list. The output is one text value containing all items separated by your delimiter.

Does CombineTextByDelimiter work in Power BI Desktop?

Yes. The M function is the same in Power BI Desktop and Excel Power Query. Menu labels may differ slightly, but the formula syntax is identical.

How do I handle null values in the list?

Nulls are treated as empty text, which can create doubled delimiters. Filter them out with List.Select before combining, or replace them with a placeholder if you need to preserve positions.

Can I use a line break as the delimiter?

Yes. Use "#(lf)" for a line feed or "#(cr)" for a carriage return in the delimiter argument.