Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS: Can you have the label of a (pie) chart be both the category AND the Percent

I have a pie chart in SSRS. It contains many categories so it is kinda hard to read. What I would like to do is include the category AND the percent in the label, but I am not sure how to do this.

You can include the category by setting the label to [CategoryName] (this is the default). You can include the percent by changing that to #PERCENT. But I cannot seam to figure out how to include both.

Is there a VBA formula that I can add that will give me both?

like image 631
ajspacemanspiff Avatar asked Oct 24 '13 14:10

ajspacemanspiff


People also ask

How do you show labels in a pie chart?

On the Layout tab, in the Labels group, click Data Labels, and then click the option that you want. For additional data label options, click More Data Label Options, click Label Options if it's not selected, and then select the options that you want.

How do I show percentages and percentages in a pie chart in Excel?

To display percentage values as labels on a pie chart On the design surface, right-click on the pie and select Show Data Labels. The data labels should appear within each slice on the pie chart.

How do I change the label options to display Percent format first?

To format data labels, select your chart, and then in the Chart Design tab, click Add Chart Element > Data Labels > More Data Label Options. Click Label Options and under Label Contains, pick the options you want.


2 Answers

You can actually just shove #PERCENT into a larger string.

Some simple data:

enter image description here

And a simple chart based on this:

enter image description here

The expression used for the labels is:

=Fields!grp.Value & ": " & "#PERCENT{P2}"

Here {P2} is controlling the formatting. You should be able to adapt to your scenario.

Alternatively, for greater control you can just add the relevant % calculation in the label expression; in the above case this would be:

=Fields!grp.Value
    & ": "
    & Format(Sum(Fields!val.Value) / Sum(Fields!val.Value, "MyDataSet"), "P2")

Which in this case gives identical results to the above.

like image 102
Ian Preston Avatar answered Oct 10 '22 21:10

Ian Preston


As explained here, you can use the #LEGENDTEXT chart keyword to write the text that corresponds to the text of the legend item into the label.

like image 29
OzW Avatar answered Oct 10 '22 20:10

OzW