Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pooja_Mishra
Helper I
Helper I

How to merge 2 or more columns into one?

I want to merge all these columns as shown in Table 1 to get a new column as 'Result Column'

Table 1:

Column 1Column 2Column 3Column 4Column 5
ABCDEF DEF 
DEF ABC MNO
GHIABCDEFJKL 
JKL GHI PQR

 

Result Column  
ABC,DEF,DEF
DEF,ABC,MNO
GHI,ABC,DEF,JKL
JKL,GHI,PQR
1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Pooja_Mishra  ,

You can use the following dax to create a new column:

Result Column =
VAR TEST1 =
    IF (
        'Table'[Column 2] = BLANK (),
        'Table'[Column 1],
        'Table'[Column 1] & "," & 'Table'[Column 2]
    )
VAR test2 =
    IF ( 'Table'[Column 3] = BLANK (), test1, test1 & "," & 'Table'[Column 3] )
VAR test3 =
    IF ( 'Table'[Column 4] = BLANK (), test2, test2 & "," & 'Table'[Column 4] )
VAR test4 =
    IF ( 'Table'[Column 5] = BLANK (), test3, test3 & "," & 'Table'[Column 5] )
RETURN
    test4

And final you will get like below:

v-luwang-msft_0-1615966695340.png

Wish it is helpful for you !

 

Best Regards

Lucien 

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @Pooja_Mishra ,

Based on your table,do like this:

Result =
VAR TEST1 =
    IF (
        'Application Catalogue_DAU'[Business Division_1] = BLANK (),
        'Application Catalogue_DAU'[Business Division],
        'Application Catalogue_DAU'[Business Division] & "," & 'Application Catalogue_DAU'[Business Division_1]
    )
VAR test2 =
    IF (
        'Application Catalogue_DAU'[Business Division_4] = BLANK (),
        test1,
        test1 & "," & 'Application Catalogue_DAU'[Business Division_4]
    )
VAR test3 =
    IF (
        'Application Catalogue_DAU'[Business Division_7] = BLANK (),
        test2,
        test2 & "," & 'Application Catalogue_DAU'[Business Division_7]
    )
RETURN
    test3

 

Return the last "test"

v-luwang-msft_0-1620092808009.png

 

 

Best Regards

Lucien

v-luwang-msft
Community Support
Community Support

Hi @Pooja_Mishra  ,

You can use the following dax to create a new column:

Result Column =
VAR TEST1 =
    IF (
        'Table'[Column 2] = BLANK (),
        'Table'[Column 1],
        'Table'[Column 1] & "," & 'Table'[Column 2]
    )
VAR test2 =
    IF ( 'Table'[Column 3] = BLANK (), test1, test1 & "," & 'Table'[Column 3] )
VAR test3 =
    IF ( 'Table'[Column 4] = BLANK (), test2, test2 & "," & 'Table'[Column 4] )
VAR test4 =
    IF ( 'Table'[Column 5] = BLANK (), test3, test3 & "," & 'Table'[Column 5] )
RETURN
    test4

And final you will get like below:

v-luwang-msft_0-1615966695340.png

Wish it is helpful for you !

 

Best Regards

Lucien 

amitchandak
Super User
Super User

@Pooja_Mishra , Try like this as new column in dax

 

[Column 1] & if(not(isblank([Column 2])),", " [Column 2], "") & if(not(isblank([Column 3])),", " [Column3], "") & if(not(isblank([Column 4])),", " [Column 4], "") & if(not(isblank([Column 4])),", " [Column 4], "")

Thanks for your response. I tried it but did not work

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.