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 table report – We will show you the steps involved in adding 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 show you the step by step approach to create a Sparkline in SSRS, and How to add it to Table report and Matrix report?. Below screenshot will show you the Data Source, and Dataset that we used for this report.
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 Add Headers and footers to SSRS Report article to understand the steps involved in adding page headers, and footers.
Add Sparkline to SSRS Table Report
In this example, we are going to create a Table report, and then add a sparkline inside that table. We can add a table to report design by dragging the table from the SSRS Toolbox to Design space. Or, simply right-click on the report designer to open the context menu. From the context menu, please select the Insert -> Table option as we shown below.
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 article to understand the steps involved in creating a table report.
Let me do some formatting to change the look of a table report. Please refer Format Table Report to understand the available formatting options.
Next, right-click on the Textbox that contains the English Product Subcategory Name will open the context menu. Please select the Row Group, and then Group Properties.
Once you select the Group Properties option, a new window will be opened as we shown below. Please click on the Add button to add Group Expression.
Next, select the Grouping column. Here it is English Product Subcategory Name
Next, let me add the Sparkline to the Empty column.
There are multiple ways to add a Sparkline in SSRS. First, simply right-click on the Empty Column to open the context menu. From the context menu, please select the Insert -> Sparkline option as we shown below.
Or, by dragging it from the SSRS Toolbox to TextBox
Either way, it will open the following window to select the sparkline type. Here, we are selecting the Line type.
Now you can see the sparkline inside the table report.
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.
Let me show you the report preview.
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 simply right-click on the report designer, and select the Insert -> Matrix option as we shown below.
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.
Let me show you the report preview.
Next, let me add a new column outside the Group.
Next, we are inserting the Sparkline inside the newly created column
This time we are using the Area Chart as Sparkline Type
Last, we added the Sales Amount column as the chart data values, Order Date as category group.
Let me show you the ssrs sparkline report preview.
As you can see from the above screenshot, we successfully added the Sparkline to Matrix report.
Let me remove the sparkline column, and add a new column inside the Row Group as we shown below.
Add Sales Amount, and Order Date as the sparkline fields
Let me show you the SSRS sparkline report preview.
Add one more metric value i.e., Total Product Cost
Well, our SSRS Sparkline is displaying both Sales Amount and Total product Cost.
Thank You for Visiting Our Blog