Click here to Skip to main content
15,888,008 members
Articles / Database Development / SQL Server / SQL Server 2012
Tip/Trick

Use Chart Item in Your SSRS Report (% Labeling)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
3 Jan 2015CPOL3 min read 19.5K   1  
How to use chart item in your SSRS Report (% labeling)

Introduction

Charts in SSRS are used to visualize data. You use Charts when you want to represent large aggregated data in visual formats.

Charts are often used in analytical dashboards, chart control provide various kinds of shapes (Pie Chart, Bar Chart, Column Chart, line Chart, ... etc.). In this tip, I will show you how to use Pie Chart in your report and how to show Percentage data labels instead of numeric (default).

Background

I used AdventureWork2012 in this example, you can download it from:

I'll assume that you created already SSRS project using SSDT, if not, please read the following articles:

Using the Code

Step 1: Open your SSRS report and create Embedded Connection of type Microsoft SQL Server and set it up to connect to AdventureWork2012 in your local machine.

Image 1

Step 2: Add Data Set and write query that return BusinessEntityID, JobTitle and Gender from HumanResources.Employee table, as shown below:

SQL
SELECT  BusinessEntityID, 
          JobTitle, 
          Gender

FROM    HumanResources.Employee

Image 2

Step 3: From Menu bar select View >> Toolbox or click Ctrl+Alt+X to show Toolbox pane.

Step 4: Drag Chart item from Report Items (Toolbox) to report designer, Select Chart Type window will pop up, browse to Shape tab and select Pie chart.

Image 3

Step 5: Double-click on the chart area, Cart Data window will show up which consists of 3 sections:

  • Values: The aggregated numeric amounts that will be grouped by Category Groups, in this example (number of employees).
  • Category Groups: The grouping field that will be used in this chart, in this example (Gender). The Columns group in the matrix is identical to the Category Groups area in the chart.
  • Series Groups: Is treated as second level group. For example, if we have parent Gender Category Group we can have child group Title. The Rows group in the matrix is identical to the Series Groups area in the chart.

Step 6: Let’s add BusinessEntityId for Values area by clicking on + sign, change the aggregation from SUM to Count.

Image 4

Step 7: In Category Groups, add Gender field. And leave Series Group empty.

Image 5

Step 8: Double-click on Chart Title, name it “Number of employees per Gender”.

Step 9: Double-click on the Pie chart >> Right click on it, select Show Data Labels, this option will show the numbers of employees in each piece. Click Preview tab to test the results.

Image 6

Step 10: Go back to design mode, Right Click on Data Labels >> Series Label Properties.

Image 7

Step 11: Series Label Properties window will pop up, from General tab select #PERCENT from Label data list. Then click OK and run the report in Preview mode.

Image 8

Finally, the report should look like the below image in preview mode:

Image 9

Points of Interest

By default #PERCENT data label comes with 2 decimal precision, if the business requirements asked for 0 decimal places, go to Series Label Properties (Step 11) and use Expression in Label data field with this value:

="#PERCENT{P0}"

Image 10

History

  • 4th January, 2015: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Database Developer
Canada Canada
My name is Ahmad Ahmad, I’m a SQL Server developer and a Microsoft Certified Professional, I have 5+ years hands-on experience in SQL Server Reporting Services, SQL Server Integration Services and SQL Database Development.

Until recently I built my own blog SQLDeft.com and published articles on SSIS, SSRS, T-SQL and DW, it's still growing, since I have had some free time I decided to dedicate my time for writing and sharing knowledge with others.

I would welcome any connect invitation on LinkedIn.

Comments and Discussions

 
-- There are no messages in this forum --