Tuesday, October 6, 2015

Pie Chart Report in SSRS





In this article, I will show you how to create Pie Chart Report in SSRS.
1. First of all open Visual Studio 2010 and create blank report as described in my previous article.
2. Now add data source and after that add data set as describe in my previous article.
In this report we used following query:
?
1
2
3
4
5
6
7
8
9
10
11
SELECT      DATEPART(Year, SOH.OrderDate) AS OrderYear, PC.Name AS ProdCat, SUM(SOD.LineTotal) AS Sales
FROM        Sales.SalesOrderHeader AS SOH INNER JOIN
            Sales.SalesOrderDetail AS SOD ON SOH.SalesOrderID = SOD.SalesOrderID INNER JOIN
            Sales.SalesPerson AS SP ON SOH.SalesPersonID = SP.BusinessEntityID INNER JOIN
            HumanResources.Employee AS E ON SP.BusinessEntityID = E.BusinessEntityID INNER JOIN
            Person.Person AS C ON E.BusinessEntityID = C.BusinessEntityID INNER JOIN
            Production.Product AS P ON SOD.ProductID = P.ProductID INNER JOIN
            Production.ProductSubcategory AS PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID INNER JOIN
            Production.ProductCategory AS PC ON PS.ProductCategoryID = PC.ProductCategoryID
WHERE       DATEPART(Year, SOH.OrderDate) = 2008
GROUP BY    DATEPART(Year, SOH.OrderDate), PC.Name
3. Now right click on report area and go to Insert–> chart.
Pie Chart Report in SSRS-1
4. A Select Chart Type window pops-up.
In that select Shape from left pane and then select Pie chart as shown in below screen:
Pie Chart Report in SSRS-2
Then click on OK button.
5. Now you will see a representation of the pie chart on the design surface.
Pie Chart Report in SSRS-3
6. Click anywhere on the chart area to activate Chart Data Window.
Click on + sign in right side of Category Groups and select ProdCat from available fields.
Similarly click on + sign in right side of Values and select Sales.
So now your chard data window looks like below:
Pie Chart Report in SSRS-4
7. Now you can see report by clicking on Preview Tab. So your result looks like below:
Pie Chart Report in SSRS-5
8. Now if you want ToolTip on Series, Right click on Series and select Series Properties from the context menu. A Series Properties Window pops-up. Then select ToolTip from the dropdown list as shown in below screen shot.
Pie Chart Report in SSRS-6
Then click on OK button.
9. Now click on Preview button to see tooltip.
Pie Chart Report in SSRS-7
10. You can also change the position of Legend. To change the position of legend, right click on legend and select Legend Properties.
Pie Chart Report in SSRS-8
11. A Legend Properties Window pops-up. In that select Legend Position.
Pie Chart Report in SSRS-9
12. Now click on Preview tab to see the results.
Pie Chart Report in SSRS-10
Congratulations! We successfully completed Pie Chart Report in SSRS.





Pie Chart in SSRS 2014


Sometimes, it can be visually good if we display the data in Pie Chart. For example, Sales by region, Country wide customers count etc. In this article we will show you, How to create and configure the Pie charts in SQL Server Reporting Services 2014
Below screenshot will show you the, Data Source and Dataset we used for this Pie Chart Report.
PIE CHART IN  SSRS 2014
SQL Command we used in the above screenshot is:
T-SQL QUERY

Creating Pie Charts in SSRS 2014

When you drag and Drop the Chart from Toolbox to Design space, a new window calledSelect Chart Type will be opened to select required chart from the available once. In this example, we are selecting Simple Pie Chart as shown in below screenshot.
PIE CHART IN  SSRS 2014
Once you click on Ok button, Pie chart will be displayed in design region with dummy data.
PIE CHART IN  SSRS 2014
Click on the empty space around the Pie Chart will open the Chart Data window
  • Values: Any Numeric (Metric) value such as sales amount, Tax, Total Sales, Customer count etc. All these values will be aggregated using aggregate function (Sum, Count etc) because we are grouping them with the category group items.
  • Category Group: Please specify the Column name on which you want to partition you Pie Chart.
PIE CHART IN  SSRS 2014
In this example, we will create Pie chart for Sales by country so, Drag and drop the Sales Amount column from dataset to chart data values and Country Name in category group.
NOTE: Please be careful when dragging the columns to values region, if you mishandled or dropped in design area will end up in mess.
PIE CHART IN  SSRS 2014
Click on the Preview button to see the report preview.
PIE CHART IN  SSRS 2014
If you observe the above screenshot, It is providing perfect result but we are unable to identify the difference between Sales in France and Sales in Germany. To resolve these situations, We have to use the Data Labels.
Right click on the pie chart and select the Show Data Labels option from the context menu to show the values
PIE CHART IN  SSRS 2014
Click on the Preview button to see the report preview.
PIE CHART IN  SSRS 2014
Thank you For Visiting Our Blog



Formatting Pie Chart in SSRS 2014


In this article we will show you, How to change the Pie Chart Title, Legend Title, Legend Position, Pie Chart Font, Pie Chart Model, Pie Chart Pallet and Display Percentage Values as Labels on Pie Chart in SQL Server Reporting Services 2014 with example.
To explain the available Format options, We are going to use below shown report. Please refer SSRS Pie Chart article to understand the Data Source and Dataset we used for this report.
FORMAT PIE CHART IN SSRS 2014

Formatting Pie Chart in SQL Server Reporting Services

Change Pie Chart Title in SSRS 2014
To change the Pie Chart title, Please select the Chart title region as we shown in below screenshot
Format  Pie Chart Title in SSRS 2014
Now, change the title as per your requirement. Here we changed as Sales By Country because the report is displaying the same
Format  Pie Chart Title in SSRS 2014
Show Pie Chart Legend Title in SSRS 2014
To display the Pie Chart Legend title, Please select the Legend region and right-click on it will open the context menu. From the menu, select Show Legend Title option as we shown in below screenshot
Format  Pie Chart Legend Title in SSRS 2014
Please rename the Legend title as per your requirement. Here we named it as Countries
Format Font and Legend Position of a Pie Chart in SSRS 2014
Select the Legend region and right-click on it will open the context menu. From the menu, please select Legend Properties option as we shown in below screenshot
Format Pie Chart Lengend in SSRS 2014
Within the General Tab we have an option called Legend Position as shown in below screenshot. You can change the Legend Position by select those dot positions
Format Pie Chart Legend Position in SSRS 2014
Next, Within the Font tab we can change the Font Size, Font Family, Font Style and Color of a Pie Chart Legend as shown in below screenshot
Format Pie Chart Legend Position in SSRS 2014
Change the Pie Chart in SSRS 2014
SSRS allows us to change the chart type even after creating the chart. First, select the Pie chart and right-click on it will open the context menu. Please select the Change Chart Type…  option from the context menu
Change Pie Chart in SSRS 2014
Once you select the Change Chart Type…  option, it will open new window to select the change. Here we are select 3D Pie chart
Change Pie Chart in SSRS 2014
Click Ok button and preview the report
Change Pie Chart in SSRS 2014
From the above screenshot you can observe that, We successfully changed the Chart Type
Change the Palette of a Pie Chart in SSRS 2014
We can also Change Pie Chart Color or Palette in SSRS. First select the Chart and goto properties. Change the color by select the Palette property as shown in below image
Format Pie Chart Color in SSRS 2014
Here we selected the Chocolate color
Format Pie Chart Color in SSRS 2014
Display Percentage Values on Pie Chart in SSRS 2014
First select the data labels on the Pie Chart and then right-click on them will open the context menu. Please select the Series Label properties… option from the context menu
Display Percentage Values on Pie Chart in SSRS 2014
Within the General Tab, Please select the Label data to #PERCENT from the drop down list. Once you select the percent a pop up window will be displayed asking, Do you want to setUseValueAsLable to false or not. Please select Yes because we are changing the default value to percent
Display Percentage Values on Pie Chart in SSRS 2014
Click Ok and click on Preview button to see the Pie Chart Preview
Display Percentage Values on Pie Chart in SSRS 2014
We successfully displayed the Percentages as Pie Chart Label
Thank You for Visiting Our Blog