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
joeheng123
Frequent Visitor

PowerBi Slicer and Matrix Visualisation Issue

Hello I have a problem, where I create a Slicer(Attribute) and select multiple items to display into the Matrix table it shows me blank spaces which I do not want to see as I only want to see the the values selected. I notice that the Matrix filter has been set to "Or". How can I change it to "And" 

For example, when I select 2 subjects on the slicer table (Attribute), it displays blank spaces and values In the Matrix However,i only  want the values to appear.sample1.PNGSample 2.PNGsample.PNG

1 ACCEPTED SOLUTION

Hi @joeheng123 ,

 

You need to drag the measure(Subject with AND-Only Condition) into filter pane and choose "is not blank" then apply filter.

1.gif

 

Hope this can help you.

 

 

Best Regards,
Xue Ding
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

7 REPLIES 7
AllisonKennedy
Super User
Super User

@joeheng123
Slicers are always an OR condition, but you can create a custom measure to get the AND result you want.

See if this post can help you out: https://community.powerbi.com/t5/Desktop/Slicer-with-quot-AND-quot-logic/td-p/592018

If you need it specific to your scenario you will need to provide sample data please.

PS, I am going to move this to Desktop thread where it will get more views and help since it is not related specifically to Power Query. Cheers!

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi,

 

Attached below is my code however it not working.

For your kind assistance please.

 

Picture 1.PNG

Picture 2.PNG

Hi @joeheng123 ,

 

Please try this:

New Table as slicer:

Subject = VALUES('Table'[Subject])

A measure:

Subject with AND-Only Condition = 
var selectedSubject=VALUES(Subject[Subject])
var countRowsFact=
COUNTROWS(
    DISTINCT(
        SELECTCOLUMNS(
            FILTER(
                'Table',
                RELATED(Subject[Subject]) in selectedSubject
                ),
                "Subject",
                RELATED(Subject[Subject])
        )
    )
)
var countRowsSubject=COUNTROWS(selectedSubject)
return
IF(countRowsFact>=countRowsSubject,countRowsFact)

 

v-xuding-msft_0-1598872690074.png

 

https://radacad.com/slicer-with-and-condition-in-power-bi#:~:text=The%20default%20behaviour%20of%20t...

 

 

 

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

Hello im having the same issue again i tried numerous times but still unable to change "Or" condition to "And" condition so that my table does not show blank spaces. can anyone assist to provide me the measure code for to copy ?

 

 

 

 

 

measure code.PNGProblem 1.PNGSample 2.PNGsample.PNGsample1.PNG

 

Hi @joeheng123 ,

 

You need to drag the measure(Subject with AND-Only Condition) into filter pane and choose "is not blank" then apply filter.

1.gif

 

Hope this can help you.

 

 

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

Hi i tried the measure code and it does not seem to work do you know how i can resolve this issue?
 
syntax error.PNG
 

Hi @joeheng123 ,

 

We need to create a relationship between the two tables while using RELATED function

v-xuding-msft_0-1599024414884.png

 

And based on the error message, there is an extra ")" in your formula. Please remove one to try again.

v-xuding-msft_1-1599024654621.png

 

I have attached my sample above. You could download it to have a try.

 

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.