Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Merge columns based on conditions

Hi All,

I have requirment 

Column1Column2Required Result
A1A1
B2B
C3C
A4A4
A5A5
D6D
E7E
F8F

Should merge the coulmn if the condition gets satisfied or else it should be as column1

 

  • Anonymous , Try a new column

     

    if([column1] ="A", [column1] & [column2], [column1] )

  • Hi Anonymous ,

     

    If you want to create a calculated column using DAX, try what amitchandak mentioned.

     

    If you want to create a custom column using M language, try this:

    = if [Column1] = "A" then [Column1] & Number.ToText([Column2]) else [Column1]

     

    If you want to create a measure, try this:

    Measure = 
    IF (
        SELECTEDVALUE ( Table1[Column1] ) = "A",
        SELECTEDVALUE ( Table1[Column1] ) & SELECTEDVALUE ( Table1[Column2] ),
        SELECTEDVALUE ( Table1[Column1] )
    )

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous , Try a new column

     

    if([column1] ="A", [column1] & [column2], [column1] )

  • Icey's avatar
    Icey
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    If you want to create a calculated column using DAX, try what amitchandak mentioned.

     

    If you want to create a custom column using M language, try this:

    = if [Column1] = "A" then [Column1] & Number.ToText([Column2]) else [Column1]

     

    If you want to create a measure, try this:

    Measure = 
    IF (
        SELECTEDVALUE ( Table1[Column1] ) = "A",
        SELECTEDVALUE ( Table1[Column1] ) & SELECTEDVALUE ( Table1[Column2] ),
        SELECTEDVALUE ( Table1[Column1] )
    )

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.