The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
Solved! Go to 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.
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]
)
Hi @Syndicate_Admin ,
Here I create a sample to have a test.
Table1:
Table2:
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.
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.
Read about SELECTCOLUMNS, VALUES and INTERSECT
SELECTCOLUMNS - make sure the columns have the same name
VALUES - get unique values
INTERSECT - find commonality
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
101 | |
82 | |
62 | |
55 |
User | Count |
---|---|
253 | |
119 | |
115 | |
95 | |
70 |