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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

DAX measure to respond only to intersection from a Slicer

Hi!

 

We have a simple problem, but the solution does not seem so simple.

 

We want to select one or multiple languages in a slicer and that the count of users speaking these languages shows the intersection. Meaning that if we select English and French in the slicer, we would see users who speak only English and French (not one or the other, as we are getting at the moment).

 

afontesc_0-1643895587544.png

This screenshot is from a sample file I have created for the post. 

 

We should be getting a count of 2, not 4, since only 2 users speak English and French.

 

The measure should be dynamic (not hard-coded). We found this suggestion online but it does not work completely as we only get the count of users when all languages are selected (1 user in this case):

 

TEST Measure =

VAR _cat = { "English", "French", "Italian" }

RETURN
COUNTAX(
VALUES( 'User Language'[ID] ),
IF(
CALCULATE(
DISTINCTCOUNT( 'User Language'[Language] ),
TREATAS( _cat, 'User Language'[Language] )
) = COUNTROWS( _cat )
, 1
)
)

 

That's all, any help on this would be much appreciated.

Thanks for your time!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I have found the solution for this, if anyone is interested -> https://www.youtube.com/watch?v=tONOosN1xAs

 

The model structure is: 

afontesc_0-1643976558854.png

 

The measure is:

#Candidates All Lan =
VAR NumOfSelectedLanguages = COUNTROWS( VALUES('Language'[Language]) )
VAR CandidatesAndLanguages =
SUMMARIZE('Talent Pool','Talent Pool'[ID],'Language'[Language])
VAR CandidatesWithNumLanguages =
GROUPBY(
CandidatesAndLanguages,
'Talent Pool'[ID],
"@Languages", SUMX( CURRENTGROUP(), 1)
)
VAR CandidatesWithAllLanguages =
FILTER( CandidatesWithNumLanguages, [@Languages] = NumOfSelectedLanguages )
RETURN
COUNTROWS( CandidatesWithAllLanguages )

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I have found the solution for this, if anyone is interested -> https://www.youtube.com/watch?v=tONOosN1xAs

 

The model structure is: 

afontesc_0-1643976558854.png

 

The measure is:

#Candidates All Lan =
VAR NumOfSelectedLanguages = COUNTROWS( VALUES('Language'[Language]) )
VAR CandidatesAndLanguages =
SUMMARIZE('Talent Pool','Talent Pool'[ID],'Language'[Language])
VAR CandidatesWithNumLanguages =
GROUPBY(
CandidatesAndLanguages,
'Talent Pool'[ID],
"@Languages", SUMX( CURRENTGROUP(), 1)
)
VAR CandidatesWithAllLanguages =
FILTER( CandidatesWithNumLanguages, [@Languages] = NumOfSelectedLanguages )
RETURN
COUNTROWS( CandidatesWithAllLanguages )
parry2k
Super User
Super User

@Anonymous check this video on my youtube channel and see if it helps.https://youtu.be/zS1IDl3DLak

 

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Check my latest video on Filters and Sparklines https://youtu.be/wmwcX8HvNxc

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi, thanks for the quick reply.

 

I have tried it using your video but it does not fully work as it is not the exact same problem.

 

I need the count in the KPI card to be correct, so if we select English and French we would obtain 2 distinct IDs who speak both English and French. 

 

This is the last DAX measure I obtained from following your video: 

Selected Language Candidate v5 =
VAR _selectedLanguage = VALUES('Language'[Language])
VAR _selectedLanguageCandidate =
CALCULATETABLE(
VALUES('User Language'[ID]),
ALL('User Language'),
TREATAS(_selectedLanguage,'Language Calculated'[Language])
)
RETURN
CALCULATE(
DISTINCTCOUNT('User Language'[ID]),
TREATAS(_selectedLanguageCandidate,'User Language'[ID])
)
 
afontesc_0-1643902510884.pngafontesc_1-1643902533998.png

(using separated Language table for the slicer)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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