cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amnadeem1991 Regular Visitor
Regular Visitor

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?
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

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

12 REPLIES 12
Super User
Super User

Re: Reverse Selection in Visuals (reverse slicer)

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.


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

amnadeem1991 Regular Visitor
Regular Visitor

Re: Reverse Selection in Visuals (reverse slicer)

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 Regular Visitor
Regular Visitor

Re: Reverse Selection in Visuals (reverse slicer)

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.
Super User
Super User

Re: Reverse Selection in Visuals (reverse slicer)

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.


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

amnadeem1991 Regular Visitor
Regular Visitor

Re: Reverse Selection in Visuals (reverse slicer)

Your response on solution will be much appreciated.
And on you later honest comment, it all depends on the requirement of analysis. In my case, our requirement is to select some items, and then to carry forward balance items to next report.... then again select some more items from those balance items, and then again to carry forward the new balance items... So, reverse selection/filter is indeed necessary.
Super User
Super User

Re: Reverse Selection in Visuals (reverse slicer)

Given this Enter Data query:

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0UIrViVZyAjKNIExnsCiE7QIWhrBdgWxjEDsWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Category = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Value", Int64.Type}})
in
    #"Changed Type"

Create Measure:

 

 

ExceptSum = CALCULATE(SUM('Except'[Value]),EXCEPT(ALL('Except'[Category]),VALUES('Except'[Category])))

Use Category as slicer. Plot ExceptSum. Done. If you need a more specific solution, you will need to supply sample data.

 

 Don't blame me if you get punched though... Smiley Happy


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

amnadeem1991 Regular Visitor
Regular Visitor

Re: Reverse Selection in Visuals (reverse slicer)

@Greg_Deckler Unfortunately, I was unable to interpret your syntax. When it comes to development/DAX, I am kind of new to power BI. Please access the sample file at following link: https://www.dropbox.com/s/0d0hwu90pk2qvo9/Table1.xlsx?dl=0.

Demo1.pngIt has 3 headers, "Category, NetValue and Year". Task is to get a list of left-over categories. Using reverse slicer, I would need to select any categories (say, Fruit and Juices), and another table (showing categories) should show the list of balance categories (other than Fruit and Juices). Similarly, once I select more categories out of balance categories using another slicer (say, hardware and software), another table should show the balance categories (all categories other than fruit, juice, hardware and software). You may refer to the attached image that shows the the target task.

Highlighted
Super User
Super User

Re: Reverse Selection in Visuals (reverse slicer)

OK, amazingly, this is actually possible. But, you are probably not going to like the solution all that much. I put your data into a table called ExceptCategories.

 

So, the first thing you do is you create a disconnected table (no relationships to anything) of all of your categories:

 

I called my CategoryExcept:

 

Category

Office Supplies
Consultancy
Fruit
Juices
PPE
Hardware
Software

 

Next, you create measures for each of your categories like this:

 

 

ConsultancySum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="Consultancy"))

FruitSum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="Fruit"))

HardwareSum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="Hardware"))

JuicesSum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="Juices"))

OfficeSuppliesSum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="Office Supplies"))

PPESum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="PPE"))

SoftwareSum = CALCULATE(SUM(ExceptCategories[NetValue]),FILTER(ALL(ExceptCategories),ExceptCategories[Category]="Software"))

Now, you create the following magical measure:

 

 

Measures to Show = 
    VAR mytable = EXCEPT(ALL(ExceptCategories[Category]),VALUES(ExceptCategories[Category]))
    RETURN
IF(
    ISFILTERED(ExceptCategories[Category]),
    IF(HASONEVALUE(CategoryExcept[Category]),
    SWITCH(VALUES(CategoryExcept[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()
    ))
)

Then, you create a Slicer based upon ExceptCategories[Category]. Then you create a table with CategoryExcept[Category] and [Measures to Show]

 

And it actually works, which is amazing.

 

 

 


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

amnadeem1991 Regular Visitor
Regular Visitor

Re: Reverse Selection in Visuals (reverse slicer)

@Greg_Deckler Great stuff, it really worked... Thanks a lot. However, either the solution is workable for 1 time selection of categories, or I am not able to make it usefull for more than 1 tables/slicers. I have uploaded the latest Excel and .pbix file on following dropbox link: https://www.dropbox.com/sh/omel37fmyevwfzd/AACmcZ227rD80ua2Rq2tqJPua?dl=0.  

 

Demo(1).pngDemo(2).pngI followed your syntax, created table (1) that simply shows overall categories. Then I created slicer (1) and table (2). When I select any categories (like, Office Supplies and PPE) from Slicer (1), the table (2) shows rest of the categories (all except Office Supplies and PPE) - That's great, and fulfills the fisrt part of requirement.... However, next to it, I need to have another slicer (2) and table (3). Once "Office Supplies and PPE" are selected from Slicer (1), the Table (2) and Slicer (2) both should show left-over categories (all except Office Supplies and PPE). Then, out of those left-over categories in Slicer (2), I need to select further categories (say, Consultancy and Hardware), then the table (3) should show only the categories selected in Slicer (2), and the table (4) should further drill down to show another list of overall balance categories (all except Office Supplies, PPE, Consultancy and Hardware). I hopw you understood the idea. Can you assist in reaching this schematic? Thank you. (If you wish to make changes in my .pbix file, please feel free to do so and share the updated file). Please also see the attached pictures to get better idea.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 6 members 1,264 guests
Please welcome our newest community members: