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?
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.
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.
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.
You can actually just shove #PERCENT
into a larger string.
Some simple data:
And a simple chart based on this:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With