Forum Discussion
Reverse Selection in Visuals (reverse slicer)
- 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.
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.
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.
- Greg_Deckler8 years agoCommunity Champion
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... :)
- amnadeem19918 years agoHelper I
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.
It 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.
- Greg_Deckler8 years agoCommunity Champion
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.