Forum Discussion

bullius's avatar
bullius
Icon for Helper V rankHelper V
10 years ago
Solved

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!

 

  • 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.

  • 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])

8 Replies

  • KGrice's avatar
    KGrice
    Icon for Memorable Member rankMemorable Member

    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.

    • bullius's avatar
      bullius
      Icon for Helper V rankHelper V

      Thanks for the reply.

       

      Table2 does not contain unique values...

      • KGrice's avatar
        KGrice
        Icon for Memorable Member rankMemorable Member

        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?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Although I have a relationship the second option is not working.