Power BI: using IF for different tables

In most of my reports, I often use the IF condition, for instance, if it is equal then do that or do this. The trick part is when I have to make reference to another table so let´s take example of those 2 tables:

Table 1 Table 2
power bi power bi

From the table2, I want to know which priorities are on the table1. There are 2 formulas that I can use. One with the CONTAINS function:

IF(CONTAINS('table1','table1'[argument1],'table2'[argument1]),"yes","no")

power bi

And the other one using those functions:

IF(CALCULATE(COUNTROWS('table1'),FILTER('table1','table1'[argument1]='table2'[argument1]))>0,"yes","no")

power bi power bi

NOTE: to specify a particular value, change 'table2'[argument1] by "value"

power bi power bi

I will add another criteria, I want to know which priorities have “unix” in the comment. In this case, I will use the second formula:

IF(CALCULATE(COUNTROWS('table1'),FILTER('table1','table1'[argument1]='table2'[argument1] && SEARCH("value",'table1'[argument2],1,0)))>0,"yes","no")

power bi

Using the first formula, I need to put exactly the full sentence of the comment:

IF(CONTAINS('table1','table1'[argument1],'table2'[argument1],'table1'[argument2],"value"),"yes","no")

power bi power bi

Interesting Topics