Reputation: 3179
I'm new to SQL Server. how can I add the values of my Pie Chart to the Legend next to the Series fields? In this case I want the percentage.
For example:
United States 43.2%
Canada 22%
etc.
Upvotes: 1
Views: 11974
Reputation: 136
Had the same wish. I am charting number of staff in a quarter by staff category. I have a simple proc that takes a date (@EOQDate - start of quarter) and lists the staff . So I added a simple total in my SELECT SQL statement...
, COUNT(staffID) OVER (PARTITION BY @EOQDate) AS StaffCount
then in SSRS design mode click on the category legend and on the bottom of the chart in the Drop category fields here section right-click on the category you dragged into this area and select Category group properties...
In the Lable box click the expression builder and build the expression you want to see. Obviously you need the existing category lable, in my case...
=Fields!StaffCategory.Value
Then add the percentage which is Count(Fields!staffID.Value)/Fields!StaffCount.Value
You'll need to turn it into a percentage, so my final expression looks like this...
=Fields!StaffCategory.Value & " " & Format(Count(Fields!staffID.Value)/Fields!StaffCount.Value, "0.00 %")
And Wullah! category lable and percentage.
Upvotes: 0
Reputation: 21
Here is the answer I use.
In the Series Proporties under Series Data you will find the Category field: (blank by default)
Enter what ever text you want and the keywords for the values you want displayed. Below are the values entered and the Legend display results.
Also Hispanic - (#VALY)
Also Hispanic - (2156)
Also Hispanic - #VALY
Also Hispanic - 2156
Also Hispanic - (#PERCENT{P1})
Also Hispanic - (21.8%)
Also Hispanic - #PERCENT{P1}
Also Hispanic - 21.8%
Upvotes: 2
Reputation: 3707
Maybe this will help http://technet.microsoft.com/en-us/library/dd239373%28SQL.100%29.aspx check the section titled "To display percentage values in the legend of a pie chart "
Upvotes: 1
Reputation: 11
In the series label properties of Chart..set #LEGENDTEXT #PERCENT{#%;;""}
Regards, Krishna
Upvotes: -1
Reputation: 1
We should be knowing the exact way of calculating the 43.2 to achieve this.
For example:
Total Number of Cycles: 20 Total Number of Cycles Used : 10 Percentage of the Cycles: 10/20 * 100 = 50 %
Now I would write the expresssion to complete this Case:
=Sum(Fields!ID.Value, "Total_Number_Of_Cycles_Used") * 100 / Sum(Fields!ID.Value, "Total_Number_Of_Cycles") & "%"
"Total_Number_Of_Cycles_Used" and "Total_Number_Of_Cycles" are the two datasets created.
For some Percentages, sometimes we would not be requiring the decimals more than 2. We could achieve it by using.
=LEFT(FORMAT(Sum(Fields!ID.Value, "Total_Number_Of_Cycles_Used") * 100 / Sum(Fields!ID.Value, "Total_Number_Of_Cycles"))) & "%"
Your Query:
="United States" & Percentage Expresssion as Mentioned Above
Hope this Helped You.
Regards
GVS
Upvotes: -1