Forum Discussion

sandraemma's avatar
sandraemma
Frequent Visitor
3 years ago
Solved

Show correct column based on its value

Hello, 

 

I am trying to create a plain table in Power BI but I am having trouble figuring out how to add a column based on values from basically two columns. I am getting duplicate rows since the rows are unique so I need to filter them out based on the value in col1.

 

Let's say I have two columns; col1 and col2

If col1 contains the string "See col2" then I want to show col2,

if col1 does not contain "See col2" then show col1 value.

 

 

Thanks for your time.

Br,

Sandra 

  • Hello , 

    give this a try 


    New Column =
    IF(
    CONTAINSSTRING(Table1[col1], "See col2"),
    Table1[col2],
    Table1[col1]
    )
    & " " &
    IF(
    CONTAINSSTRING(Table1[col1], "See col2"),
    "",
    DISTINCT(Table1[col1])
    )

    Regards, 
    Please consider accepting this as a solution !! Respect your KUDO !! 
    I appreciate your recognition and feel proud to have been able to assist you.


1 Reply

  • bhelou's avatar
    bhelou
    Responsive Resident

    Hello , 

    give this a try 


    New Column =
    IF(
    CONTAINSSTRING(Table1[col1], "See col2"),
    Table1[col2],
    Table1[col1]
    )
    & " " &
    IF(
    CONTAINSSTRING(Table1[col1], "See col2"),
    "",
    DISTINCT(Table1[col1])
    )

    Regards, 
    Please consider accepting this as a solution !! Respect your KUDO !! 
    I appreciate your recognition and feel proud to have been able to assist you.