How to Use CONCATENATEX in DAX in Power BI
Use
CONCATENATEX in DAX to join text values from a table or column into one string, separated by a delimiter you choose. It takes a table, an expression to evaluate for each row, and a delimiter to combine the results.Syntax
The CONCATENATEX function combines text values from multiple rows into a single string with a specified delimiter.
It has three main parts:
- Table: The table or table expression to iterate over.
- Expression: The column or expression to extract text from each row.
- Delimiter: The text used to separate the combined values.
DAX
CONCATENATEX(<Table>, <Expression>, <Delimiter>)
Example
This example shows how to join all product names from a Products table into one string separated by commas.
DAX
ProductList = CONCATENATEX(Products, Products[ProductName], ", ")Output
If Products contains: Apple, Banana, Cherry
Output: "Apple, Banana, Cherry"
Common Pitfalls
Common mistakes include:
- Using a column that contains numbers without converting them to text first.
- Forgetting to specify a delimiter, which defaults to no separator and can make the output hard to read.
- Passing a scalar value instead of a table as the first argument.
Always ensure the first argument is a table and the expression returns text or is converted to text.
DAX
/* Wrong: Using a number column without conversion */ WrongConcat = CONCATENATEX(Products, Products[ProductID], ", ") /* Right: Convert number to text */ RightConcat = CONCATENATEX(Products, FORMAT(Products[ProductID], "0"), ", ")
Quick Reference
| Parameter | Description |
|---|---|
Table | Table or table expression to iterate over |
Expression | Column or expression to extract text from each row |
Delimiter | Text string to separate concatenated values |
Key Takeaways
CONCATENATEX joins text values from multiple rows into one string with a delimiter.
Always pass a table as the first argument and a text expression for the second.
Specify a delimiter to separate values clearly, like a comma or space.
Convert non-text columns to text before concatenation to avoid errors.
Use CONCATENATEX to create readable lists or summaries in your Power BI reports.