Forum Discussion

DavidWaters100's avatar
DavidWaters100
Post Patron
6 years ago
Solved

Pir to switch or toggle between Type and Sub-type

Hi,

 

I am trying to getr a pie chart to switch or toggle.  When a user selects one "Type" in a slicer, the pie should show "Sub-type".  When they select "ALL", the pie should show "Type".  The reason for this toggle is because there are too many sub-types when "ALL" is selected.  Below link to a dummy re-creation - my method to do this was a distinct count of type.  So when "All" is selected the count is >1, but it does not work!

 

Any ideas how to do this please, or where I went wrong in file below?

 

thanks

 

https://www.dropbox.com/s/rzn35c28jqufiv1/pie%20toggle%20example.pbix?dl=0

5 Replies

  • negi007's avatar
    negi007
    Community Champion

    DavidWaters100you can achieve the desired result by using unpivot feature in power query window. In this way, you will have 3 columns one column which has numeric value, second column which will have main or sub-filter value, and 3rd column which will have all filter values. Below is the screenshot for your reference. 

     

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi  DavidWaters100 

    "Type" and "Sub-type" are different dim fields, Slicer is just used to filter data, it could not switch between different dim field in a visual.

     

    So as a workaround, you could unpivot "Type" and "Sub-type"column into one column, then use that column in a visual and use attribute column as a slicer to switch it.

    https://radacad.com/pivot-and-unpivot-with-power-bi

     

    Regards,

    Lin

    • DavidWaters100's avatar
      DavidWaters100
      Post Patron

      Thanks for your comments and replies.  In the end I decided to duplicate my sheet and add a button to navigate to that duplicated sheet where "All" was pre-selected and the "Type" pie was showing.  I added another button to return to the other sheet where user can choose a Type but not "All" - in this sheet the pie for "Sub-Type" is showing.  Bit of a workaround but user just clicks on an "All" button or goes back to choose different Types, and the pie appears to switch like that.