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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
furret
New Member

Quick slicer with AND

Hi everyone!

 

I would like to create a slicer with and logic. There are some details.

 

I have a really big table with numbers (of employees) and skills, here languages for simplicity.

Employees:

NumberLanguage
5472English
5472German
5472Dutch
5472Esperanto
5472Chinese
4577English
4577German
4577Dutch
4577Esperanto
7289English
9956German
6924Japanese
6924Chinese

 

I also have a table with other employees' details

NumberTeamAvailable
5472A01.01.2023
4577A13.01.2023
7289B01.02.2023
9956C31.01.2023
6924C01.01.2023

 

Employees and Skills are correlated by number.

3.PNG

 

Now I want to have slicers for Team, Availability and Languages selection but I want to get only people who know for example English and German and something else.

 

 

2.PNG

 

My solution for AND-filtering is as follows:

* create a table with distinct languages (named Languages)

* create 3 measures

Number of selected languages (Language slicer is on this created table):

 

 

NSkillsFiltered = IF( ISFILTERED(Languages[Language]), COUNTROWS(VALUES(Languages[Language])),0)

 

 

 

Number of appearances of certain employee number in the filtered table

 

 

NEmployeesWithSelectedSkills = 
CALCULATE(
    COUNTROWS(FILTER(ALLSELECTED(Skills),Skills[Number]=MAX(Skills[Number])))
)

 

 

 

And a check if these measures agree (so e.g., we have 2 languages selected and an employee appears in the filtered table twice):

 

 

NSkillsAgreed = IF([NEmployeesWithSelectedSkills]=[NSkillsFiltered],1,0)

 

 

 

Then I have a filter NSkillsAgreed >= 1 for my visualisation. And that works but in reality Skills table is really big and this solution seems to be rather slow. 

 

Could you help me find something faster and probably more elegant?

 

 

1 ACCEPTED SOLUTION

@furret You should be able to do this:

 

Cohort = 
  VAR tmpTable1 = 
    GENERATE(
      DISTINCT(Employees[Number]),
      EXCEPT(
        DISTINCT(Employees[Language]),
        CALCULATETABLE(DISTINCT(Employees[Language]))
      )
    )
  VAR tmpTable2 = SUMMARIZE(tmpTable1,Employees[Number])
  VAR tmpTable3 = EXCEPT(Distinct(Employees[Number]),tmpTable2)
  VAR Result = CONCATENATEX(tmpTable3,[Number],",")
RETURN
  Result

This is one of the recipes included in my book, DAX Cookbook with a full explanation of how it works.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
furret
New Member

@Greg_Deckler Your solution looks great and is really fast but I guess I am still a beginner with Power BI and I am struggling to generalize your solution so that I can also display info about availability or team.

 

Do you have any hints how can I adjust?

@furret You should be able to do this:

 

Cohort = 
  VAR tmpTable1 = 
    GENERATE(
      DISTINCT(Employees[Number]),
      EXCEPT(
        DISTINCT(Employees[Language]),
        CALCULATETABLE(DISTINCT(Employees[Language]))
      )
    )
  VAR tmpTable2 = SUMMARIZE(tmpTable1,Employees[Number])
  VAR tmpTable3 = EXCEPT(Distinct(Employees[Number]),tmpTable2)
  VAR Result = CONCATENATEX(tmpTable3,[Number],",")
RETURN
  Result

This is one of the recipes included in my book, DAX Cookbook with a full explanation of how it works.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@furret https://community.powerbi.com/t5/Quick-Measures-Gallery/Patient-Cohort-AND-Slicer/td-p/391883



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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