Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi, I am trying to compare columns from two tables that are both linked to the same (but different) table.
Below is an example of what I am trying to accomplish, Table C is the main table and it has relationships to both Table A, and Table B. Table A and Table B do not inherently relate to each other.
I would like to count the number of rows of tableC where the related TableA name and TableB name are not equal.
I have tried:
Calculate( count(tableC[Row]), related(TableA[Name]) <> related(TableB[Name]))
But get errors. Any help would be appreciated.
Table A
ID1 | Name |
1 | Jack |
2 | Jill |
3 | John |
4 | Jim |
Table B
ID2 | Name |
1 | Bill |
2 | Bob |
3 | John |
4 | Harry |
Table C
Row | ID1 | ID2 |
1 | 1 | 2 |
2 | 1 | 4 |
3 | 2 | 4 |
4 | 3 | 1 |
Solved! Go to Solution.
[Count of Diffs] =
SUMX(
'Table C',
var NameA = RELATED( 'Table A'[Name] )
var NameB = RELATED( 'Table B'[Name] )
return
1 * (NameA <> NameB)
)
For RELATED to work one has to have a row context present. In your formula, there's no row context. In my formula SUMX supplies the context. This is why your formula doesn't work.
Your formula reveals that your knowledge of DAX is rather starting to be discovered 🙂 Please grab yourself a good book on DAX and read. Trust me - I know what I'm saying. The best book by far on DAX is "The Definitive Guide to DAX" by Marco Russo and Alberto Ferrari.
This worked like a charm. Thanks for the help.
[Count of Diffs] =
SUMX(
'Table C',
var NameA = RELATED( 'Table A'[Name] )
var NameB = RELATED( 'Table B'[Name] )
return
1 * (NameA <> NameB)
)
For RELATED to work one has to have a row context present. In your formula, there's no row context. In my formula SUMX supplies the context. This is why your formula doesn't work.
Your formula reveals that your knowledge of DAX is rather starting to be discovered 🙂 Please grab yourself a good book on DAX and read. Trust me - I know what I'm saying. The best book by far on DAX is "The Definitive Guide to DAX" by Marco Russo and Alberto Ferrari.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
7 | |
6 | |
5 |
User | Count |
---|---|
20 | |
11 | |
10 | |
9 | |
6 |