Getting Started with Sparklines in SQL Server Reporting Services
Sparklines are small charts that you can embed into cells of a table or matrix. Because of their size they do not show labels or a legend, although there are many similarities with the charts you use in other parts of a report.
Because of their small size and lack of labels, sparklines are best used to show trends over time, or for comparing rows of data. In the example used in this section’s Try it, the sparkline will show trends of sales over a year for each sales person. The reader will be able to see which sales person is increasing sales over the year, but the sparkline will not provide any values.
Because sparklines use a series of data values, they must be placed in a cell that is part of a group.
Because sparklines are usually used to compare data presented in a column, it is common to align the data points with other sparklines in that column so that the reader can quickly look down the column and compare rows.
SPARKLINES SHOWING TRENDS INSIDE A TABLE ROW
1. Create a new report called Sparklines with a report data source that references the shared data source in the project.
2. Create a dataset with this query:
MONTH(soh.OrderDate) AS [Month],
p.FirstName + p.LastName AS FullName,
SUM(soh.TotalDue) AS TotalDue
INNER JOIN Person.Person p
ON p.BusinessEntityID = soh.SalesPersonID
YEAR(soh.OrderDate) = 2007
p.FirstName + p.LastName,
3. Drag a Matrix onto the report design surface
4. From the dataset, drag Month onto the Column cell, FullName onto the row cell, and TotalDue onto the data cell
5. Preview the report and supply the year parameter to check that it shows one row for each person, and one column for each month, with the total sales in the data cells
6. Back in Design view, right click on the Month column header and choose Insert Column > Outside Group – Right.
7. From the Toolbox, drag a Sparkline onto the second row of the new column.
8. Select the default column type and click ok
9. Click on the sparkline to open the Chart Data window and use the + icon to add the TotalDue field to the list of values.
10. Add a category group and select Month.
11. Right-click on the sparkline and choose Horizontal Axis Properties.
12. Tick the box to ‘Align axes in’ and accept the default selection (which will be the name of the Matrix). Click OK and preview the report.