4 Replies Latest reply: Jul 3, 2012 11:30 AM by Bill Bois RSS

    Counting the Slices in a Pie Chart

    Bill Bois

      How can I count the number of slices in a pie chart?


      The sheet I'm working on has a slider and a couple of pie charts.  When the user slides the slider, it changes the Dimension Limits on the first pie chart to "Show only values that accumulate to" n% of results, based on revenue, with n being the number specified by the slider.  That part works perfectly.


      On a second pie chart, I want to show exactly the same slices (but showing volume instead of revenue).  A little research showed me the way to do this is to have a calculated dimension that's something like:


      =Aggr(If(Rank(Sum(Revenue))<=$(vNumberOfSlices), ClientName), ClientName)


      But I need to figure out the number of slices in the first pie chart.  I've tried things like GetSelectedCount() and GetAlternativeCount() but they obviously don't work.  Any suggestions?






        • Re: Counting the Slices in a Pie Chart
          Stefan Wühl

          I don't think you can retrieve the number of chart elements (like pie slices) from within another chart object.


          For special settings, you can maybe work with the aggr() function to rebuild the dimension limit of your first chart in the second (there will probably arise an issue from the fact that aggr() dimensions will be sorted by load order, and you can't force another sort order that you will need to sum up e.g. by largest values).


          What you can try is using the same dimension and dimension limits as in your first chart, but use your original expression only for the dimension limit (that will use the first expression), i.e. hide it for presentation (and show a second expression to present your real data, e.g Volume).


          Unfortunately, hiding an expression is not an option in a pie chart, but for example in a bar chart. So this method will only work for some chart types.


          Alternatively, you can use a pareto select action to actually selecting the dimension values. Doing so will affect both charts.


          See attached a sample of both approaches.


          Hope this helps,