Dax Function: CONCATENATEX

Category: Text Functions

The CONCATENATEX function in Power BI is a DAX function used to concatenate (join) text values from multiple rows of a table or the result of an expression evaluated for each row. It allows you to specify a delimiter to separate the concatenated values.

Purpose

To combine multiple text values or expressions from rows into a single string, optionally separated by a delimiter.

Calculations Performed

This function iterates over a table, evaluates an expression for each row, and concatenates the results into a single text string, using the specified delimiter.

Practical Use Cases

  • Generating comma-separated lists of values from a column (e.g., “John, Jane, Smith”).
  • Creating custom summaries or labels for grouped data in reports.
  • Building descriptive fields by combining multiple data attributes.

CONCATENATEX(table, expression, [delimiter], [order_by_expression], [order])

ParameterTypeDescription
tableTableThe table containing the rows to iterate over.
expressionExpressionThe expression to evaluate for each row.
delimiterString(Optional) The delimiter to use between concatenated values. Defaults to empty.
order_by_expressionExpression(Optional) Specifies the column or expression for ordering.
orderString(Optional) Sort order (“ASC” or “DESC”). Defaults to “ASC”.

How Does CONCATENATEX Dax Function Works

  1. Iterates over the rows of the given table.
  2. Evaluates the provided expression for each row.
  3. Concatenates the resulting values, inserting the delimiter between each.
  4. (Optional) Orders the results based on the specified expression and sort direction.

Formula Logic Example:

For a table of names:

CONCATENATEX(NamesTable, NamesTable[Name], ", ")

Result: "John, Jane, Smith"

What Does It Return?

The function returns a single text string containing the concatenated values of the evaluated expression, separated by the specified delimiter.

When Should We Use It?

  • To summarize values from multiple rows into a single field.
  • To display aggregated text data in tooltips, cards, or custom labels.
  • For constructing dynamic messages, like lists of products purchased by a customer.

Examples

Basic Usage

Combine values from a column with a delimiter.


CONCATENATEX('Orders', 'Orders'[ProductName], ", ")

Result (Example): "Apples, Bananas, Oranges"

Column Usage:

Concatenate column values, ordered alphabetically.


CONCATENATEX('Orders', 'Orders'[ProductName], ", ", 'Orders'[ProductName], ASC)

Result (Example): "Apples, Bananas, Oranges"

Advanced Usage

Combine values dynamically using an expression.


Result (Example): "Apples: 10; Bananas: 15; Oranges: 20"

Result: "Total Sales: 5000" (assuming SUM('Sales'[Amount]) equals 5000).

Tips and Tricks

  • Performance Optimization: Use calculated columns or pre-aggregated tables for large datasets to improve performance.
  • Order Results Explicitly: Always use order_by_expression and order to ensure consistent output order.
  • Avoid Null Values: Use IF or COALESCE functions to handle nulls, as they can cause unexpected results.

Performance Impact of CONCATENATEX DAX Function:

  • The function can become resource-intensive when used on large datasets, especially with complex expressions or sorting.
  • Use filters to narrow the rows being evaluated for better performance.

Related Functions You Might Need

  • COMBINEVALUES: Concatenates multiple strings with a specified delimiter but does not iterate over rows.
  • CONCATENATE: Joins exactly two strings into one.
  • TEXTJOIN (Excel): A similar function for Excel users.

Want to Learn More?
For more information, check out the official Microsoft documentation for CONCATENATEX You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What is the purpose of the CONCATENATEX function in Power BI?

To concatenate text values from multiple rows of a table, with an optional delimiter.

2. How is CONCATENATEX different from CONCATENATE?

CONCATENATE combines exactly two text strings, while CONCATENATEX works on multiple rows and allows the use of expressions and delimiters.

3. Can CONCATENATEX order the concatenated values?

Yes, you can use order_by_expression and order parameters to control the order.

4. What happens if there are null values?

Null values are ignored in the concatenation. Use IF or COALESCE to handle them explicitly.

5. Is CONCATENATEX suitable for large datasets?

It works for large datasets but can impact performance. Optimize by filtering rows or using calculated columns.