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
Arial12
Frequent Visitor

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 12
v-yulgu-msft
Employee
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

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

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

can't merge them. both are very large tables

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!

Tables don't have a relationship.

As far as I know, you will have to create a relationship between the tables in order to compare between them. This may require creating an extra column on each of them to use as a link.

Then how do you know which values to compare?

Each table has a column with a matching value with each other..

Each table has a column with a matching value with each other..

Is there a reason that you cannot create a relationship based on those columns?

yes, one is only Numeric and another one allows alph numeric values as well. 

Anonymous
Not applicable

Convert the numeric column to text and create a relationship between the two. If you need to run calculations off the column that then can use the VALUE function or create a duplicate column using a numeric data type.

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.

Top Solution Authors