Excel & Data

Fixing DAX CONCATENATE Limit: How to Combine More Than Two Text Strings

You're building a Power BI report, and you need to combine data from several text columns into a single, clean string. Perhaps you want to create a full address from separate street, city, and state fields, or maybe you need to merge product name and SKU for a unique identifier. When you try to combine more than two columns using the DAX CONCATENATE function, you quickly hit a wall. This is a common roadblock for Power BI users trying to concatenate more than two columns, and it’s frustrating when your formula throws an error.

Juno School Data Analysis with DAX in Power BI course thumbnail
Recommended Course on JunoData Analysis with DAX in Power BI
View Course →

The Goal: Combining City and State with a Separator

Let's set up a typical scenario. Imagine you have a dataset with separate columns for City and State, and your objective is to create a new column that displays these two pieces of information together, separated by a hyphen, like "Los Angeles - California". This kind of text manipulation is fundamental for creating user-friendly reports and dashboards in Power BI. Understanding how to combine text columns in Power BI DAX effectively is key to presenting clean data.

The Common Mistake: Using CONCATENATE for More Than Two Items

Many users, when first encountering this task, naturally reach for the CONCATENATE function. It seems like the logical choice for joining text strings. However, if you attempt to combine your City and State columns with a separator using CONCATENATE like this:

CONCATENATE([City], " - ", [State])

You'll quickly discover that this formula results in an error. The reason, as explained in our Power BI courses, is that the CONCATENATE function in DAX is designed to accept only two arguments. It joins two text strings into one, not more than two. So, when you try to pass three arguments ([City], the separator " - ", and [State]), the function simply won't work. This is why you might see an error indicating that concatenate takes only two arguments power bi.

The Correct Method: Using the Ampersand (&) Operator

When you need to combine more than two text strings or columns in Power BI, the solution lies in the versatile ampersand (&) operator. This operator provides a much more flexible way to perform text concatenation in DAX. Instead of being limited to two arguments, you can chain multiple text strings, column references, and literal text values together.

To achieve our goal of combining City and State with a hyphen separator, the correct DAX formula using the ampersand operator is:

City & " - " & State

This formula directly concatenates the content of the City column, followed by the literal string " - ", and then the content of the State column. The result is exactly what we aimed for: a unified text string like "Los Angeles - California". This method is particularly useful when you need to perform dax concatenate with separator, as it allows easy insertion of spaces, hyphens, or any other characters between your combined data points. For more advanced data cleaning techniques before concatenation, you might find our guide on how to clean messy Excel data in Power BI helpful.

The flexibility of the Power BI ampersand operator means you can add as many elements as you need. For instance, if you wanted to include a country, you could simply extend the formula: City & " - " & State & ", " & Country. Once you click enter, you will see the combined data appearing in your new column, with the desired gaps and separators.

Code Summary: Your Copy-Paste Solution

For your immediate problem of combining more than two text strings or columns in Power BI, here's the DAX formula you can copy and paste into a new calculated column:

City & " - " & State

Simply replace City and State with the actual names of your columns. This will successfully combine your desired text elements, bypassing the CONCATENATE function's two-argument limitation. Many such practical tips and tricks are covered in Juno's Data Analysis with DAX in Power BI course, designed to help you master Power BI's powerful language.

Ready to level up your career?

Join 5 lakh+ learners on the Juno app. Certificate courses in Hindi and English.

Get it onGoogle Play
Download on theApp Store