Forum Discussion

amnadeem1991's avatar
amnadeem1991
Helper I
8 years ago
Solved

Reverse Selection in Visuals (reverse slicer)

I have 2 visuals on my dashboard. One visual is a Line chart, showing Spend Values by Categories. The other visual is a slicer, showing list of all Categories (say, A B C D and E). On usual basis, when I select any categories (like A and B), the line chart shows spend related to those selected categories. However, my requirement is opposite to that. Means, when I select Category A and B in slicer, the line chart should show all the data except related to Category A and B . . . . The Reverse Selection!
Is there any DAX or Visual or Interaction available to enable this task?
  • Greg_Deckler's avatar
    Greg_Deckler
    8 years ago

    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.

14 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Honestly, that's weird. Make sure slicer is mulit-select, make sure that Select All is turned all. Select all, uncheck A and B. Done.

    • amnadeem1991's avatar
      amnadeem1991
      Helper I
      I tried turning on each parameter, but does not work.
      Actually, i followed the solution as per following post: http://community.powerbi.com/t5/Desktop/Slicer-reverse-selection-in-chart/m-p/96316#M40562.
      But, it allows only single reverse selection.
      Please can you share any syntax or demo example that can be used to make my case useful? My intention is to select items in slicer, and the line chart should show all the data except the selected items in slicer. Means, reverse filter.
    • amnadeem1991's avatar
      amnadeem1991
      Helper I
      Again stating my requirement, If I select category A and B in slicer, the line chart should show data related to Category C and D. Whatever is selected in slicer, line chart should show the rest of the data, and not the one related to selected items.
      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        I'll have to study that solution and see if I can come up with a way to apply it to your situation. It appears similar to a disconnected table trick. Honestly though, if someone handed me a report that worked that way the first thing I would do is punch them. Then I would fire them and then I would punch them again for good measure. That just seems like an amazingly counter-intuitive way to design a report that way.