cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vijay_Kumar_P
New Member

Hello, I need help with Dax code to concatenate few columns.

Sample data:

Vijay_Kumar_P_0-1668169992679.png

 

For example, I want to concatenate C1,C2,C3,C4 columns and I don't want to include Null values in the Output Column. 

 

Thanks in advance.

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

I would do that kind of thing in the query editor, but here is a DAX column expression you can use. A virtual table is created with { }, filtered to remove blanks, and then the results are concatenated with no delimiter. Replace T1 with your actual table name.

Concat =
VAR ValuesAsTable =
    FILTER ( { T1[C1], T1[C2], T1[C3], T1[C4] }, [Value] <> "" )
RETURN
    CONCATENATEX ( ValuesAsTable, [Value], "" )

ppm1_0-1668172062877.png

 

Pat

Microsoft Employee

View solution in original post

2 REPLIES 2
ppm1
Solution Sage
Solution Sage

I would do that kind of thing in the query editor, but here is a DAX column expression you can use. A virtual table is created with { }, filtered to remove blanks, and then the results are concatenated with no delimiter. Replace T1 with your actual table name.

Concat =
VAR ValuesAsTable =
    FILTER ( { T1[C1], T1[C2], T1[C3], T1[C4] }, [Value] <> "" )
RETURN
    CONCATENATEX ( ValuesAsTable, [Value], "" )

ppm1_0-1668172062877.png

 

Pat

Microsoft Employee
FreemanZ
Community Champion
Community Champion

You can add a new column with the code below:

 

Expected Output = Data[C1]&Data[C2]&Data[C3]&Data[C4]

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!