cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

If column contains values from column in another table...

Hello

 

I would like a column that shows whether or not a column in Table2 contains values that are in Table1.

 

Table1 
ValueNew Column
ATRUE
BFALSE
CTRUE
DFALSE
E

TRUE

Table2
Value
A
C
E

 

Any Ideas?

 

Thanks!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Solution Sage
Solution Sage

Re: If column contains values from column in another table...

Hi @bullius. If table 2 contains only unique values, you could relate the two tables on the Value column, and then use this formula for your New Column:

 

New Column = NOT(ISBLANK(RELATED(Table2[Value])))

 

You can also use the formula below, which will work with or without the relationship:

 

New Column = CALCULATE(COUNTROWS(Table2), FILTER(Table2, Table2[Value]=Table1[Value])) > 0

 

See this post for more information about how each method works.

View solution in original post

Highlighted
Impactful Individual
Impactful Individual

Re: If column contains values from column in another table...

I know KGrice's formula worked but it does seem a tad clunky... you could consider this as a slightly cleaner alternative (since the CONTAINS function exists exactly for this purpose):

 

Column = CONTAINS(Table2, Table2[Value], Table1[Value])

View solution in original post

7 REPLIES 7
Highlighted
Solution Sage
Solution Sage

Re: If column contains values from column in another table...

Hi @bullius. If table 2 contains only unique values, you could relate the two tables on the Value column, and then use this formula for your New Column:

 

New Column = NOT(ISBLANK(RELATED(Table2[Value])))

 

You can also use the formula below, which will work with or without the relationship:

 

New Column = CALCULATE(COUNTROWS(Table2), FILTER(Table2, Table2[Value]=Table1[Value])) > 0

 

See this post for more information about how each method works.

View solution in original post

Highlighted
Helper V
Helper V

Re: If column contains values from column in another table...

Thanks for the reply.

 

Table2 does not contain unique values...

Highlighted
Solution Sage
Solution Sage

Re: If column contains values from column in another table...

Hi @bullius. The unique values piece only matters for creating a relationship. The second option I listed does not require unique values in either table. Were you able to get that one working?

Highlighted
Helper V
Helper V

Re: If column contains values from column in another table...

Yes! The second one does the job. Thanks!

Highlighted
Impactful Individual
Impactful Individual

Re: If column contains values from column in another table...

I know KGrice's formula worked but it does seem a tad clunky... you could consider this as a slightly cleaner alternative (since the CONTAINS function exists exactly for this purpose):

 

Column = CONTAINS(Table2, Table2[Value], Table1[Value])

View solution in original post

Highlighted
Solution Sage
Solution Sage

Re: If column contains values from column in another table...

Thanks, @jahida. I hadn't come across the CONTAINS function yet. I'll start using that instead.

Highlighted
Helper I
Helper I

Re: If column contains values from column in another table...

 but with this method, there has to be a relationship established between tables, right ?

Helpful resources

Announcements
Super Users of the Quarter - Q2 2020

Super Users of the Quarter - Q2 2020

Who are our Super User Superstars? Who made it to the top of the leaderboards? Get the answers!

June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors