Sparkline in SSRS

In this article, we will show you how to create Sparkline in SSRS with an example. As most of the followers are asking about the sparklines in the table report – We will show you the steps involved in adding SSRS Sparklines to Table Report and Matrix report.

For this SSRS Sparklines example, we are going to write the Custom SQL Query against the SQL Server Data Source, and the query that we are going to use for this report is:

-- SQL Query that we used in SSRS Sparkline
SELECT Prodcat.EnglishProductCategoryName,
              prodSubcat.EnglishProductSubcategoryName,  
              prod.EnglishProductName, 
              prod.Color, 
              fact.[TotalProductCost],
              fact.SalesAmount, 
              fact.TaxAmt,
              fact.[OrderDate],
              fact.[ShipDate] 
FROM dbo.DimProduct as prod 
   INNER JOIN  dbo.DimProductSubcategory AS prodSubcat ON 
               prod.ProductSubcategoryKey = prodSubcat.ProductSubcategoryKey 
   INNER JOIN  dbo.DimProductCategory AS Prodcat ON 
                prodSubcat.ProductCategoryKey = Prodcat.ProductCategoryKey 
   INNER JOIN  dbo.FactInternetSales AS fact ON 
                 fact.ProductKey = prod.ProductKey

Create Sparkline in SSRS Example

This example shows you the step by step approach to create a Sparkline in SSRS and how to add it to Table report and Matrix report?. The below screenshot will show you the Data Source and Dataset that we used for this SSRS report.

Sparkline in SSRS 1

To demonstrate the steps involved in adding the Sparkline in SSRS Report, We are going to use the previously generated report that we shown below. Please refer to Add Headers and footers to SSRS Report article to understand the steps involved in adding page headers and footers.

Sparkline in SSRS 2

Add Sparkline to SSRS Table Report

In this example, we are going to create a Table report, and then add a sparkline inside that SSRS table. We can add a table to report design by dragging the table from the SSRS Toolbox to Design space. Or, right-click on the report designer to open the context menu. Please select the Insert -> Table option from it.

Sparkline in SSRS 3

As you can see, we added the English Product Subcategory Name as the first column, and also removed the third column from the table. I suggest you to refer Create a New Table Report to understand the steps involved in creating a table report.

Sparkline in SSRS 4

Let me do some formatting to change the look of a table report. Please refer to the Format Table Report to understand the available formatting options.

Sparkline in SSRS 5

Next, right-click on the Textbox that contains the Product Subcategory Name will open the context menu. Please select the Row Group, and then Group Properties.

Sparkline in SSRS 6

Once you select the Group Properties option, a new window will open, as shown below. Please click on the Add button to add Group Expression.

Sparkline in SSRS 7

Next, select the Grouping column. Here it is English Product Sub-category Name

Sparkline in SSRS 8

Next, let me add the Sparkline to the Empty column.

There are multiple ways to add a Sparkline in SSRS. First, right-click on the Empty Column. From the context menu, please select the Insert -> Sparkline option.

Sparkline in SSRS 9

Or, by dragging Sparkline from the SSRS Toolbox to TextBox

Sparkline in SSRS 10

Either way, it will open the following window to select the sparkline type. Here, we are choosing the Line type.

Sparkline in SSRS 11

Now you can see the sparkline inside the table report in SSRS.

Sparkline in SSRS 12

Click on the empty space around the sparkline will open the Chart Data window. Here we want to see the Total Product cost by Order Date Trend. So, Drag and drop the Total Product cost column from dataset to chart data values, Order date to category group.

Sparkline in SSRS 13

Let me show you the SSRS Sparkline report preview.

Sparkline in SSRS 14

Add Sparkline to SSRS Matrix Report

In this example, we are going to create a Matrix report, and then add a ssrs sparkline inside that Matrix.

We can add a Matrix by dragging the Matrix report item from the SSRS Toolbox to Design space. Or we can right-click on the report designer, and select the Insert -> Matrix option.

Sparkline in SSRS 15

As you can see, we added the English Product Subcategory Name as the Row Group and Sales Amount. I suggest you to refer Create a New Matrix Report article to understand the steps involved in creating a Matrix report.

Sparkline in SSRS 16

Let me show you the report preview.

Sparkline in SSRS 17

Next, let me add a new column outside the Group.

Sparkline in SSRS 18

Next, we are inserting the SSRS Sparkline inside the newly created column

Sparkline in SSRS 19

This time we are using the Area Chart as Sparkline Type

Sparkline in SSRS 20

Last, we added the Sales Amount column as the chart data values, Order Date as a category group.

Sparkline in SSRS 21

Let me show you the SSRS sparkline report preview.

Sparkline in SSRS 22

As you can see from the above screenshot, we successfully added the Sparkline to Matrix report in SSRS.

Let me remove the sparkline column and add a new column inside the Row Group.

Sparkline in SSRS 23

Add Sales Amount, and Order Date as the sparkline fields

Sparkline in SSRS 24

Let me show you the SSRS sparkline report preview.

Sparkline in SSRS 25

Add one more metric value i.e., Total Product Cost

Sparkline in SSRS 26

Well, our SSRS Sparkline is displaying both the Sales Amount and Total Product Cost.

Sparkline in SSRS 27