Measure intersection between two tables in Power BI

Let's assume that you have a 'Siblings' table:

ASCII
| Name     | Age |
|----------|-----|
| Andrea   | 30  |
| Paula    | 18  |
| Erik     | 33  |

And also the following 'Names' table:

ASCII
| Name     | Age |
|----------|-----|
| Erik     | 25  |
| Sarah    | 30  |
| Michael  | 28  |

In Power BI, suppose you wish to determine the number of common names in the 'Name' column between two tables using a measure. Below is an example measure you can create:

DAX
Measure = 

// Read both tables
var table_1 = ALL('Siblings')
var table_2 = ALL('Names')

// Get only column 'Name'
var sum_1 = SUMMARIZE(table_1, 'Siblings'[Name])
var sum_2 = SUMMARIZE(table_2, 'Names'[Name])

// We get the intersection between both tables
var com_12 = INTERSECT(sum_1, sum_2)

// Get distinct values between both tables
var dis_12 = DISTINCT(com_12)

// Return number of common names
return COUNTROWS(dis_12)

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.