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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

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

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]
    )
v-rzhou-msft
Community Support
Community Support

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.