Forum Discussion

Arial12's avatar
Arial12
Frequent Visitor
7 years ago

Case like statements - Compare two table columns

Hi Experts,

 

I have two table with similar column that i want to compare and calculate a column.

 

something like this,

 

if tabl1.col1 = tabl2.col1 then "yes" else "NO"

 

any suggestion?

 

 

Thanks,

12 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Merge the tables into a new one in Power Query, then you can easily achieve what you want.

    • Arial12's avatar
      Arial12
      Frequent Visitor

      can't merge them. both are very large tables

      • Christann's avatar
        Christann
        Advocate IV

        Try creating a relationship between the tables and then use a function like:

        isequal = IF(Table[Column1]=RELATED(Table2[Column1]),"yes","no")

        Hope this helps!

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi Arial12,

     

    Based on my assumption, there existing a common field between two tables, which can determine the matching relationship between tables, right? And you want to compare the col1 in both tables, right? If so, please try below formula to create a calculated column.

    New column =
    IF (
        tab1[col1]
            = LOOKUPVALUE ( tab2[col1], tab2[matchingcolumn], tab1[matchingcolumn] ),
        "Yes",
        "No"
    )

    Best regards,

    Yuliana Gu