Forum Discussion
Slicer by columns name
- 9 years ago
Hi Anonymous,
I would solve this using a measure do the following:
- Create a table (do not related this with any other tables with the following structure:
- Name Slicer - Selection: Unity_Price, Tax_1, Tax_2, Tax_3, Tax_4
- Add the following measure to your data table:
Final_Price = VAR Unity_price = IF ( CONTAINS ( Slicer, Slicer[Selection], "Unity_Price" ) = TRUE (), SUM ( Sales[Unity_Price] ), 0 ) VAR Tax1 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_1" ) = TRUE (), SUM ( Sales[Tax_1] ), 0 ) VAR Tax2 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_2" ) = TRUE (), SUM ( Sales[Tax_2] ), 0 ) VAR Tax3 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_3" ) = TRUE (), SUM ( Sales[Tax_3] ), 0 ) VAR Tax4 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_4" ) = TRUE (), SUM ( Sales[Tax_4] ), 0 ) RETURN Unity_price + Tax1 + Tax2 - Tax3 - Tax4- Now just add the valuies from the table you created to a slicer and your measure to the table should give the expected result:
Regards,
MFelix
- Create a table (do not related this with any other tables with the following structure:
Hi Anonymous,
I would solve this using a measure do the following:
- Create a table (do not related this with any other tables with the following structure:
- Name Slicer - Selection: Unity_Price, Tax_1, Tax_2, Tax_3, Tax_4
- Add the following measure to your data table:
Final_Price = VAR Unity_price = IF ( CONTAINS ( Slicer, Slicer[Selection], "Unity_Price" ) = TRUE (), SUM ( Sales[Unity_Price] ), 0 ) VAR Tax1 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_1" ) = TRUE (), SUM ( Sales[Tax_1] ), 0 ) VAR Tax2 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_2" ) = TRUE (), SUM ( Sales[Tax_2] ), 0 ) VAR Tax3 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_3" ) = TRUE (), SUM ( Sales[Tax_3] ), 0 ) VAR Tax4 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_4" ) = TRUE (), SUM ( Sales[Tax_4] ), 0 ) RETURN Unity_price + Tax1 + Tax2 - Tax3 - Tax4- Now just add the valuies from the table you created to a slicer and your measure to the table should give the expected result:
Regards,
MFelix
Hi MFelix I have similar issue and i want to create a slicer where column name will be slicer and when i click on slicer it should change the data in teh donut.
Please see the screenshot below where is have shown my whole data. I am not sure where to upload PBIx file and attaching screeshot here.. Here is the table:
| BadgeID | Job Title | Country | FirstName | LastName | BoothNumber | Booth Name | Duration Seconds |
| 123 | Engineer | USA | abc | Woods | 27 | Booth 1 | 600 |
| 456 | Engineer | Germany | def | Woods | 27 | Booth 1 | 480 |
| 789 | Engineer | India | ghi | Sa | 27 | Booth 1 | 1320 |
| 532 | Chief Information Officer | USA | jkl | Va | 14 | Booth 2 | 240 |
| 1182304 | Operations Manager | USA | Chet | Manchester | 21 | Booth 3 | 980 |
| 1182523 | Account Manager | USA | Travis | Fulton | 21 | Booth 3 | 1080 |
| 1182657 | Senior Engineer | India | Luisa | Sangines | 21 | Booth 3 | 1680 |
| 1182879 | Engineer | USA | Mark | Skallet | 21 | Booth 3 | 480 |
| 1149995 | Analyst | USA | Megan | Hemmila | 37 | Booth 4 | 1200 |
| 1149995 | Analyst | India | Megan | Hemmila | 37 | Booth 4 | 2280 |
| 1150180 | Architect|Partner | India | Hoa | Tram | 37 | Booth 4 | 1200 |
| 1150180 | Architect|Partner | Germany | Hoa | Tram | 37 | Booth 4 | 480 |
| 117 | Senior Engineer | USA | pqr | Pa | 14 | Booth 2 | 360 |
- MFelix8 years ago
Super User
Hi Anonymous,
You can do this making of 3 options
- Dynamic Hierarchie
- Unpivot Columns
- Bookmarks
- Dynamic Hierarchie
Using this post I adapted the situation and made the following
- Created a new table with the following code:
Country Job Hierarchy = UNION ( SELECTCOLUMNS ( 'Hierarchy'; "Badge ID"; 'Hierarchy'[BadgeID]; "Hierarchy Name"; 'Hierarchy'[Job Title]; "Level"; "Job Title"; "LevelNumber"; 1 ); SELECTCOLUMNS ( 'Hierarchy'; "Badge ID"; 'Hierarchy'[BadgeID]; "Hierarchy Name"; 'Hierarchy'[Country]; "Level"; "Country"; "LevelNumber"; 2 ) )j
- Make a relationship between this table and your main table by BadgeID: be aware that this will create a many to many relationship. If you don't have the latest version of PBI you need to make a dimension table for Uniques BadgeID and then relate this with the two other table
- Make this relationship with a cross filter in both directions
- Add the Column Hierarchy name to your legend and the count of what ever field you want from the main table.
2. Unpivot Column (link to unpivot columns)
- Query Editor Select both country and Job title column
- Transform Unpivot
- Get 2 columns atribute and value
- Add Attribute to slicer and value to legend in chart
3. Bookmarks (link to bookmarks documentation)
- Create two buttons Job title Country
- Create two donut charts one with job title and the cother with country on legend
- Hide the Job Title chart and create the bookmark named country and make it an action of the Country button and vice-versa
- Then just click on the buttons (on desktop version you have to use CTRL + CLICK)
See below the screenshot and the PBIX file with all the options above.
Regards,
MFelix
- Anonymous8 years agoNot applicable
HI MFelix, Thats superb!,
I liked you have posted 3 methods and i found Unpivot is easy for me since I am not expert in Dax code. I have used your method in my table using Unpivot and everthing looks great except i have one more requirment which i forgot to mention in previous post.
1) I want to show the Top 5 values in the chart, I tried to add Visual level filter but nothing happened.
2) I saw that Donut Chart is showing value for Both Attribute in single chart but I want to show either Country or JobTitle only at the same time. Can we select one value by default or is there any other method to achive the same? In the real data I have 7 attributes that need to be shown in one donut chart.
Please see the attached screenshot:
I found that Bookmark mehtod is good if we don't have any other slicer in the chart but when we use multiple slicer that change the chart Bookmark method is failed.
Thank you so much for the detail answer.
Kulchandra
- Anonymous7 years agoNot applicable
Hi MFelix ,
I am trying to achieve something similar and I really like the Dynamic hierarchies option and is also suitable for my requirement. I have created a new table using the DAX query and joined with the main table, the totals in the two result sets is same but the breakdown is not right. I am not sure why this is happening, please tell me if I am missing anything.
Results from New TableResults from Main Table
Thanks in advance
- MFelix7 years ago
Super User
HI Anonymous ,
Without any specification and data about your model is difficul to give you an answrr, but have you checked if you hierarchy model is linked in a many to many relationship and with cross filtering active?
Can you share your file? If information is sensitive do a mockup file or shared it trough private message.
Regards,
MFelix
- Anonymous7 years agoNot applicable
T.H.I.S.I.S.A.W.E.S.O.M.E!!
Thank you MFelix
- MFelix7 years ago
Super User
Hi Anonymous,
Don't know how I could help with this post but glad it serves your purposes.
:smileyhappy::smileyhappy::smileyhappy::smileyhappy::smileyhappy:
Regards,
MFelix