Sparklines
A sparkline is a special type of chart that fits within a single cell. Typically, these are column charts or line charts that are particularly useful for showing changes over time. Excel offers many fewer options for formatting sparklines, but like in-cell bar charts, they have the tremendous advantage of being shown with the data itself.
How do the number of purchases vary by month for different payment types? To answer this question, let’s focus on a single year, 2015. The idea is to summarize the orders data by month and then create sparklines that show the changes through the year.
The query to extract the data uses conditional aggregation:
SELECT PaymentType, SUM(CASE WHEN MONTH(OrderDate) = 1 THEN 1 ELSE 0 END) as Jan, . . . SUM(CASE WHEN MONTH(OrderDate) = 12 THEN 1 ELSE 0 END) as Dec FROM Orders o WHERE YEAR(OrderDate) = 2015 GROUP BY PaymentType ORDER BY PaymentType
The...