cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User IV
Super User IV

Re: Reverse Selection in Visuals (reverse slicer)

I'll see if I can find some time to take a look at this. This just seems like a ton of work to get to something that is done incredibily easily by just using select all and then unselecting the things you don't want. At that point, what you are asking for is absolutely trivial and will work without any code what-so-ever. I'm not getting the business case where selecting an item from a slicer is so vastly different than unselecting a value from a slicer.


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Super User IV
Super User IV

Re: Reverse Selection in Visuals (reverse slicer)

OK @amnadeem1991, I believe I have it.. What I did was duplicate my disconnected table CategoryExcept as CategoryExcept1. This should also be a completely disconnected table (not connected to CategoryExcept or ExceptCategories in my model.

 

Then, create your second slicer based upon CategoryExcept, your original disconnected table. Edit interactions to not have this slicer filter the table that you have that you created with the original "Measures to Show". Now, create the following measure:

 

Measures to Show 1 = 
    VAR mytable1 = EXCEPT(ALL(CategoryExcept[Category]),VALUES(CategoryExcept[Category]))
    VAR mytable = EXCEPT(mytable1,VALUES(ExceptCategories[Category]))
    RETURN
IF(
    ISFILTERED(ExceptCategories[Category]),
    IF(HASONEVALUE(CategoryExcept1[Category]),
    SWITCH(VALUES(CategoryExcept1[Category]),
        "Consultancy",IF(CONTAINS(mytable,[Category],"Consultancy"),[ConsultancySum],BLANK()),
        "Fruit",IF(CONTAINS(mytable,[Category],"Fruit"),[FruitSum],BLANK()),
        "Hardware",IF(CONTAINS(mytable,[Category],"Hardware"),[HardwareSum],BLANK()),
        "Juices",IF(CONTAINS(mytable,[Category],"Juices"),[JuicesSum],BLANK()),
        "Office Supplies",IF(CONTAINS(mytable,[Category],"Office Supplies"),[OfficeSuppliesSum],BLANK()),
        "PPE",IF(CONTAINS(mytable,[Category],"PPE"),[PPESum],BLANK()),
        "Software",IF(CONTAINS(mytable,[Category],"Software"),[SoftwareSum],BLANK()),
        BLANK()
    ))
)

You should notice that this is exactly the same as the original "Measures to Show" measure (uses the same measures you previously created) except for the first two VAR lines and the references to CategoryExcept1 instead of CategoryExcept. Effectively, what those two VAR lines are doing are taking all of your category values, excluding the values selected in your first slicer and then excluding the values you selected in your second slicer. Create a table visualization with the Category from CategoryExcept1 and this new "Measures to Show 1" and you should have what you are looking for. In theory, you could essentially continue this technique ad infinitum.


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

Highlighted
piyushmohnot Regular Visitor
Regular Visitor

Re: Reverse Selection in Visuals (reverse slicer)

HI @Greg_Deckler,

This approach is nice but it will work only for limited records. As in this case, categories are near about 10. What if records increases to 100. Then how am I supposed to create query for all of them? I have same requirement of reverse filtering where records are 'users' and slicer is 'date'.

 

Here is my query : https://community.powerbi.com/t5/Desktop/Non-Filtered-Data/m-p/482048#M14791

 

Thanks,

Piyush

Helpful resources

Announcements
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors