Monday, September 21, 2015

How to add Chart to your SSRS report

You can add charts to your SSRS reports.

A typical chart contains 3 parts: Category Groups, Series Groups, and Values. You can treat a chart like a matrix, which has columns, row, and data. Category Groups in the chart is like columns in the matrix. Series Groups in the chart is like rows in the matrix. And the values in the chart is like data in the matrix.

Right click on the white part of the report design page, and choose Chart then a default chart will add to your report. 


Right click on the chart you just added, a Chart Data window will popup so you can choose Category Groups, Series Groups, and Values. 

For example, I need to compare two years sales data month by month. I put following SQL script into the dataset:

SELECT Sum (dbo.FactFinance.Amount) AS SumCount
    ,  dbo.DimDate.MonthNumberOfYear
     , dbo.DimDate.EnglishMonthName
     , dbo.DimDate.CalendarYear
FROM  dbo.FactFinance
    INNER JOIN dbo.DimDate on dbo.FactFinance.DateKey = dbo.DimDate.DateKey
Where dbo.DimDate.CalendarYear = @Year1 OR dbo.DimDate.CalendarYear = @Year2
GROUP BY dbo.DimDate.CalendarYear, dbo.DimDate.MonthNumberOfYear,
    dbo.DimDate.EnglishMonthName
ORDER BY dbo.DimDate.CalendarYear, dbo.DimDate.MonthNumberOfYear

I set CalendarYear as Category Group, and set EnglishMonthName as Series Group, and SumCount as Value. 

Also I need to order Series Group by MonthNumberOfYear, so I right click on the EnglishMonthName under Series Group, and choose MonthNumberOfYear as following.


The report is done. The source DB is from Microsoft AdventureWorksDW2012. The result would be like this.


Source:
https://msdn.microsoft.com/en-us/library/dd239351.aspx

No comments:

Post a Comment