The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Solved! Go to Solution.
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.
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'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.
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... 🙂
@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.
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.
Hi Greg,
The information you shared is greatly helpful, thank you. This works great when only one value is selected in slicer. But failing for multiple selection (e.g. "Consultancy" and "Fruit") with error "table value was returned by the expression when single value was expected". Can you please suggest how to address it?
@giramswa I think I solved this here:
Inverse Selector - Microsoft Power BI Community
@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.
I 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.
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.
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.
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
79 | |
71 | |
48 | |
41 |
User | Count |
---|---|
138 | |
108 | |
71 | |
64 | |
58 |