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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Syndicate_Admin
Administrator
Administrator

Count common values between tables that are not related

Nice day

I ask for your help, I need to create a DAX expression to count the common values between two tables that are not related. In both tables what I have in common are the identification numbers of the people, however, they are multiple records that are repeated in both tables.

I thank you for the help you can give me.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Syndicate_Admin ,

 

I suggest you to try code as below.

VAR _LIST =
    CALCULATETABLE (
        VALUES ( Table2[Record] ),
        FILTER ( Table2, Table2[ID] = MAX ( Table1[ID] ) )
    )
RETURN
    CALCULATE ( COUNTROWS ( Table1 ), FILTER ( Table1, Table1[Record] IN _LIST ) )

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

Thank you very much for the help, however, I need the DAX formula to apply it for example on a card to show me the result of the count, of the values that in this case would have the two tables in common in the ID field

Anonymous
Not applicable

Hi @Syndicate_Admin ,

 

I suggest you to try code as below.

VAR _LIST =
    CALCULATETABLE (
        VALUES ( Table2[Record] ),
        FILTER ( Table2, Table2[ID] = MAX ( Table1[ID] ) )
    )
RETURN
    CALCULATE ( COUNTROWS ( Table1 ), FILTER ( Table1, Table1[Record] IN _LIST ) )

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Maybe try this.

Count = 
    SUMX(
        'Table1',
        [Measure]
    )


Proud to be a Super User!

daxformatter.com makes life EASIER!
Anonymous
Not applicable

Hi @Syndicate_Admin ,

 

Here I create a sample to have a test.

Table1:

vrzhoumsft_0-1696400294089.png

Table2:

vrzhoumsft_1-1696400306777.png

Measure:

Measure = 
VAR _LIST = CALCULATETABLE(VALUES(Table2[Record]),FILTER(Table2,Table2[ID] = MAX(Table1[ID])))
RETURN
IF(MAX(Table1[Record]) IN _LIST,1,0)

Add this measure into visual level filter and set it to show items when value = 1.

vrzhoumsft_2-1696400343908.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

lbendlin
Super User
Super User

Read about SELECTCOLUMNS, VALUES and INTERSECT

 

SELECTCOLUMNS - make sure the columns have the same name

VALUES - get unique values

INTERSECT - find commonality

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors