Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
hello,
I have a table like this :
Key | Value |
Store 1 | Apple |
Store 1 | Orange |
Store 2 | Apple |
Store 2 | Banana |
Store 2 | Orange |
Store 3 | Banana |
Store 3 | Orange |
I would like to display a card where, when I select 2 stores, I get the number of values they have in common.
I tought of creating a table like that :
key 1 | key 2 | (Calculated column) Nb shared values |
Store 1 | Store 2 | 2 |
Store 1 | Store 3 | 1 |
Store 2 | Store 1 | 2 |
Store 2 | Store 3 | 1 |
Store 3 | Store 1 | 1 |
Store 3 | Store 2 | 1 |
That way I can filter on key 1 and key 2 and display the Nb shared values.
Is it the right way to do it ? If yes, how do I compute the "Nb shared values" column with DAX ?
Thanks in advance for your help.
You have to have 2 tables with unique Stores only so that you can select 2 stores independently.
"Store 1" Table:
Key
Store 1
Store 2
Store 3
...
"Store 2" Table:
Key
Store 1
Store 2
Store 3
...
These tables will not be connected to the table that holds Key and Values. If one store is selected from Store 1 and one is selected from Store 2, then here's a measure that will calculate the number of values they have in common:
[# Values In Common] =
var __store1 = selectedvalue( 'Store 1'[Key] )
var __store2 = selectedvalue( 'Store 2'[Key] )
var __values1 =
CALCULATETABLE(
DISTINCT( StoresWithValues[Value] ),
treatas( __store1, StoresWithValues[Key] )
)
var __values2 =
CALCULATETABLE(
DISTINCT( StoresWithValues[Value] ),
treatas( __store1, StoresWithValues[Key] )
)
var __result =
COUNTROWS(
INTERSECT(
__values1,
__values2
)
)
return
__result
Best
D
Hi Greg,
Thanks for your quick answer !
It looks like it coud be the solution 🙂 I will test it.
But can you please explain to us how did you construct your measure ? I don't get it ...
InCommon = VAR students1 = FILTER(ALL(Students),Students[Teacher]=MAX(Teachers[Teacher])) VAR students1a = SELECTCOLUMNS(students1,"MyStudent",[Student]) VAR students2 = FILTER(ALL(Students),Students[Teacher]=MAX(Teachers2[Teacher])) VAR students2a = SELECTCOLUMNS(students2,"MyStudent",[Student]) VAR incommon = COUNTROWS(INTERSECT(students1a,students2a)) RETURN IF(ISBLANK(incommon),0,incommon)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |