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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
FreemanZ
Super User
Super User

how to check if a row exists in another table

hi All,

 

Supposing I have two tables:

table1:

KeyStatusStatusDate
Ticket1To Do8/16/2022
Ticket1To Do9/8/2022

table2:

KeyStatusMinDate
Ticket1To Do8/16/2022

 

I would like to add a calculated column in table1: 

if the row in table1 exist in table2, returns "include", otherwise "exclude". like this

KeyStatusStatusDateCheck
Ticket1To Do8/16/2022include
Ticket1To Do9/8/2022exclude

 

I have this question trying to solve another question posted by MikiMihaela27. 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-...

 

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1669818878746.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1669818878746.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @FreemanZ 

Try with this solution

Check 2 = IF(RELATED('Table 2'[status date])=('Table 1'[Status date]) &&
RELATED('Table 2'[key])=('Table 1'[key]) &&
RELATED('Table 2'[status]) =('Table 1'[status]),
"Include","Exclude")
 

Best Regards,
Shreya Mukkawar

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

Hi @FreemanZ ,

1. Create a calculated column.

Check = IF(RELATED('Table 2'[status date])=('Table 1'[Status date]),"Include","Exclude")
 
shreyamukkawar_0-1669783558091.png

 

Best Regards,
Shreya Mukkawar

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

thank you. @Anonymous , that is very enlightening, but the comparison needs to be done for all columns for a certain row. 

Hi @FreemanZ ,

I think you can create a unique key column in both the tables based on concating the ticket and date column, 

After that you can use lookup value function and get the second table unique to the first table unique key based on first table's unique key.

After this you can another calculated column with if condition on the new lookuped column saying if it is blank then exclude else include.

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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