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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to change condition (AND / OR) of a slicers

Hello,

When I do a multiple selection in a slicer, I would choose the condition (AND / OR) for that selection. How can I do?

 

Example:

 

I have this filter: 

 

Slicer
A
B
C
D
E

 

And this table: 

 

CodeAtrtibute
Code1A
Code2B
Code3A
Code4C
Code5C
Code6A
Code1B
Code2B
Code3E
Code1D
Code2A
Code3C
Code4B
Code5E
Code6A

 

If I select "A"  "B" from the slicer, than I would choose the condition "AND" (having code1, code2, code3, code6) or the condition "OR" (having code1, code2).

 

Thank you.

1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

In your scenario, we can create another table with values "AND", "OR" to create a slicer, then create a distinct table with the Distinct() function, then we cna create a measure to judge it:

Measure = var a = CONCATENATEX(FILTER(ALL('Table'),'Table'[Code] = MIN('Table'[Code])),'Table'[Atrtibute],"")
var b = IF(MIN('Table'[Atrtibute]) in ALLSELECTED(Table2[Slicer]),1,0)
var c = IF(a = CONCATENATEX(ALLSELECTED(Table2[Slicer]),Table2[Slicer],""),1,0)
return IF(SELECTEDVALUE(Table3[Column1]) = "AND", c,b)

By the way, the logic of your "AND", "OR" is strange, generally, when I select "OR" and "AB", it should return 1,2,3,4,6.

PBIDesktop_hglIGxqD58.png

Best Regards,

Teige

View solution in original post

3 REPLIES 3
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

In your scenario, we can create another table with values "AND", "OR" to create a slicer, then create a distinct table with the Distinct() function, then we cna create a measure to judge it:

Measure = var a = CONCATENATEX(FILTER(ALL('Table'),'Table'[Code] = MIN('Table'[Code])),'Table'[Atrtibute],"")
var b = IF(MIN('Table'[Atrtibute]) in ALLSELECTED(Table2[Slicer]),1,0)
var c = IF(a = CONCATENATEX(ALLSELECTED(Table2[Slicer]),Table2[Slicer],""),1,0)
return IF(SELECTEDVALUE(Table3[Column1]) = "AND", c,b)

By the way, the logic of your "AND", "OR" is strange, generally, when I select "OR" and "AB", it should return 1,2,3,4,6.

PBIDesktop_hglIGxqD58.png

Best Regards,

Teige

Anonymous
Not applicable

Hi @TeigeGao, thank you for the reply.

 

You're right, I wrote a wrong thing. I would say: If I select "AB" from the slicer, then I select "AND" it should return code1, code2 while selecting "OR" it should return code1, code2, code3, code4, code6.

 

By the way, I can't replicate your indications.

I think I'm missing something.

 

So, I have: Table (Code, Attribute) ; Table2 (Slicer) - that has unique values of the column attribute- ; Table3 (Slicer Option)

 

CodeAtrtibute
Code1A
Code2B
Code3A
Code4C
Code5C
Code6A
Code1B
Code2B
Code3E
Code1D
Code2A
Code3C
Code4B
Code5E
Code6A

 

Slicer
A
B
C
D
E

 

Slicer Option
AND
OR

 

Then I created the measure as you suggest:

 

Measure = var a = CONCATENATEX(FILTER(ALL('Table');'Table'[Code] = MIN('Table'[Code]));'Table'[Atrtibute];"")
var b = IF(MIN('Table'[Atrtibute]) in ALLSELECTED(Table2[Slicer]);1;0)
var c = IF(a = CONCATENATEX(ALLSELECTED(Table2[Slicer]);Table2[Slicer];"");1;0)
return IF(SELECTEDVALUE(Table3[Slicer Option]) = "AND"; c;b)
 
What I have to do next?
Thank you,
clara100

Hi @Anonymous ,

We need to use distinct() function to create a calculated table whose name is "Table", then we can create the measure.

Best Regards,

Teige

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors