Balu
Balu

Reputation: 21

DAX, Power BI - Concatenate strings

Does anyone know a DAX that could concatenate rows for the example in the image? I want to create a new measure that would englobe all countries together but summing up the repeated ones. BR + BRA would be Brasil.

Example here

I can add up the values for those countries in a DAX which would return numbers, but I am interested in strings specifically. Something like "if in country BR and BRA then Brasil, if in country CH and CHI then Chile".

Thanks!

Upvotes: 1

Views: 2757

Answers (3)

KARTHIKEYAN.A
KARTHIKEYAN.A

Reputation: 20118

use & to concatenate strings

Ex:

"String1 " & "String2" & " String3" => String1 String2 String3

Subheading = "for events that occured up to "& FORMAT(TODAY(),"DD") & "th  " & FORMAT(TODAY(),"MMMM") & "

Result: for events that occured up to 16th December

enter image description here

Upvotes: 0

Marc
Marc

Reputation: 1

Do you mean a measure that concatenate multiple strings into a single comma-delimited string? If so, you may want to use CONCATENATEX iterator. More specifically, in Power BI Desktop, you can create a measure using the Quick Measure option, and then selecting the "concatenate..." option at the bottom. This will give you a code snippet that does that, and a good starting point.

Upvotes: 0

Alexis Olson
Alexis Olson

Reputation: 40244

Create a calculated column that unifies the countries.

all_countries =
SWITCH(
    TRUE();
    'panelCmd'[country] IN { "BR", "BRA" }; "Brasil";
    'panelCmd'[country] IN { "CH", "CHI" }; "Chile";
    'panelCmd'[country] IN { "ES", "ESP" }; "Spain";
    <...et cetera...>
    'panelCmd'[country]
)

Then you can use that column in your table instead of / in addition to country.


Reference on SWITCH(TRUE()...): The Diabolical Genius of “SWITCH TRUE”

Upvotes: 1

Related Questions