Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Reply
Anonymous
Not applicable

Comparing columns from 2 indirectly related tables

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

ID1Name
1Jack
2Jill
3John
4Jim

 

Table B

ID2Name
1Bill
2Bob
3John
4Harry

 

Table C

RowID1ID2
112
214
324
431
1 ACCEPTED SOLUTION
Anonymous
Not applicable

 

 

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This worked like a charm. Thanks for the help. 

Anonymous
Not applicable

 

 

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.