Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DAX Contains with filter condition

Hi,
I have 2 tables (TableA and TableB) both have Name fields and TableB has a field called Status. Now, I want to compare both the tables on the Name field.
Condition 1: Compare only the Names that have the status = TRUE in TableB with the names in TableA.

Condition 2: After the comparison, return the output as "Matched" if both the tables have that name. If not, return "Not-Matched".
I tried something like this, but not able to put the filter to select only status = TRUE from TableB.

 

 

COLUMN = IF(
CONTAINS('TableB','TableB'[Name] ,'TableA'[Name])
, "Matched"
, "Not-Matched"
)

 

 

This is how my tables look like

TableA
Name
Smith
Joe
John
Paul
Arjun
Rahul
Ajay
Rajesh

 

TableB
NameStatus
SmithTRUE
JoeTRUE
JohnFALSE
PaulTRUE
RahulTRUE
RajeshTRUE
AjayFALSE
ArjunFALSE

 

Can someone please help, with the same?

Thanks in advance!

  • Anonymous , Try a new column in Table B

    new column = if(isblank(countx(filter(TableA, TableA[NAme] =TableB[Name]),TableA[Name])),"False","True")

2 Replies

  • Anonymous , Try a new column in Table B

    new column = if(isblank(countx(filter(TableA, TableA[NAme] =TableB[Name]),TableA[Name])),"False","True")

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 
    Your dax is check whether the table contains the names in other table. If that is the case, you can try create this column in TableB. 

     

    new column = IF([Name] in VALUES(TableA[Name])&&[Status]=TRUE(),"Matched","Not Matched")

     

    If you want to compare names in each row, use this column:

     

    new column = IF([Name]=RELATED(TableA[Name])&&[Status]=TRUE(),"Matched","Not Matched")

     

     

    Both dax returns the same results with your sample table, but there is a difference if you applied it to real data.


    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.