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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MG06
Regular Visitor

Help with DAX for slicers - multiple selections and default value

Hello everyone! Can you help me? I’m new to PowerBI

 

I have a table ("MockupTest") that has names and the primary/secondary skills of those people, something like this:

 

MockupTest
      Name                Primary Skills                 Secondary Skills          
IrinaA, B, CG, H, I, E
AmyD, E, FI, C, H
BobD, B, C

A, E

 

I'm trying to make a single slicer to filter both columns ("Primary Skills" and "Secondary Skills), where you can select each of the skills (for example, just "A" or "B"). Right now, I created a new table called "Skills_metric" where I added the column "Skills" and each row has only one skill, like:

 
Skills_metric
    Skills     
A
B
C...
 
Inside this table, I created a metric with this code:

filterSkills = VAR a = IF (CONTAINSSTRING(VALUES ('MockupTest'[Primary Skills]), VALUES ('Skills_metric'[Skill]))
|| CONTAINSSTRING(VALUES ( 'MockupTest'[Secondary Skills] ), VALUES ( 'Skills_metric'[Skill])),
1, 0)
RETURN IF ( ISFILTERED ( 'Skills_metric'[Skill] ), a, 0 )

 

Then used the column "Skills" in the slicer and put the metric "filterSkills" inside the filters for the "MockupTest" table. 

 

This is working fine with single selections but doesn't allow me to pick multiple selections in the slicer. Also, the default value is no row at all (just the headers appear if you don’t select any skill in the slicer).

 

Can someone correct my code or give me a new one? The expected result would be something like this:

 

Selected: "A" and "B"

     Name             Primary Skills             Secundary Skills         
IrinaA, B, CG, H, I, E
BobD, B, C

A, E

 

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MG06 

You can refer to the following measure

Measure = var a=COUNTROWS(FILTER(VALUES('Table (2)'[Skills]),CONTAINSSTRING(SELECTEDVALUE('Table'[Primary Skills]),[Skills])))
var b=COUNTROWS(FILTER(VALUES('Table (2)'[Skills]),CONTAINSSTRING(SELECTEDVALUE('Table'[Secondary Skills]),[Skills])))
return IF(OR(a>0,b>0),1,0)

Then put the measure to the visual filter

vxinruzhumsft_0-1687748390869.png

Output

vxinruzhumsft_2-1687748696089.png

 

Best Regards!

Yolo Zhu

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

2 REPLIES 2
Anonymous
Not applicable

Hi @MG06 

You can refer to the following measure

Measure = var a=COUNTROWS(FILTER(VALUES('Table (2)'[Skills]),CONTAINSSTRING(SELECTEDVALUE('Table'[Primary Skills]),[Skills])))
var b=COUNTROWS(FILTER(VALUES('Table (2)'[Skills]),CONTAINSSTRING(SELECTEDVALUE('Table'[Secondary Skills]),[Skills])))
return IF(OR(a>0,b>0),1,0)

Then put the measure to the visual filter

vxinruzhumsft_0-1687748390869.png

Output

vxinruzhumsft_2-1687748696089.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

This worked perfectly!! Thank you 😄

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.