0
votes

I have a query that pulls back a table with only a single row and 4 columns. There is one column for each Quarter of the year (Q1, Q2, Q3, Q4). The total sales is listed for each quarter.

I'm trying to make a sparkline to represent quarter-to-quarter sales in Microsoft SSRS Report Builder 3.0.

However, all of the tutorials I find online want the dataset to be structured differently. The online tutorials want me to have a table with two columns (Quarter & Sales) and four rows (one row for each quarter of data).

Is there a way for me to make a sparkline for my sales data without having to restructure my dataset? In other words, I need a way to create a sparkline that represents datapoints across different columns in a single row of a table.

1

1 Answers

0
votes

I don't see a way it can be done with your data the way it is. The chart wouldn't know where to chart the data for each of the fields.

On the other hand, you would just need to wrap your query in an UNPIVOT:

SELECT * 
FROM (SELECT 1 AS Q1, 2 AS Q2, 3 AS Q3, 4 AS Q4) AS DATA 
UNPIVOT
(
  VALUE
  FOR QUART IN (Q1, Q2, Q3, Q4)
) U; 

Of course if you use the data elsewhere, you'd need to use another dataset just for this.