DATA ANALYST
Download my resume
View My LinkedIn Profile
View My Tableau Public Profile
Sparklines can be used to show the variation of a variable or its trend over time. In other words, it is mostly used to represent the time-series data. They are line charts but without the x-axis and y-axis and their corresponding values. They are made to fit in a small area of the dashboard and can give information on the trend of a measure for different members of a dimension.
For this I have used the global superstore orders data. I will be creating a sparkline to show the variation or trend of sales in different regions of the USA. So add a context filter to filter out USA’s data in the given superstore data.
Then right click the Order Date pill and select the Month (May 2015) so that the variable is changed to continuous format (pill will become green).
Then drag the dimension region and measure sales to the row shelf. The resulting image will be like this:
Now resize the sheet such that the whole chart comes up in a compact area and the trends are clearly visible.
// For each region and month, calculate the sum of sales. Then for each region calculate the maximum
IF SUM({ FIXED [Region]: MAX({FIXED [Region], DATETRUNC('month',[Order Date]) : SUM([Sales])})})
= SUM([Sales])
THEN SUM([Sales])
// For each region and month, calculate the sum of sales. Then for each region calculate the minimum
ELSEIF
SUM({ FIXED [Region]: MIN({FIXED [Region], DATETRUNC('month',[Order Date]) : SUM([Sales])})})
= SUM([Sales])
THEN SUM([Sales])
END
Add the calculated field so as to form a dual axis and synchronize it with the main axis. Also right click on nulls and click hide indicators and uncheck Header. Now we can see the minimum and maximum points on the sparklines. (Though the color of the lines and points may vary)
Now right click on the Sales, Min or Max Points and Month of Order Date axis and uncheck the headers for Sales, Min or Max Points and Month of Order Date.
Now right click on the axis for region and click format and then remove the Grid lines, zero lines, ref lines and borders.
Now we can reduce the thickness of sparklines by modifying the size of the marks card for sales and then we can increase the size of points which denote the maximum and minimum point by selecting circle in the dropdown menu of AGG(Min or Max points) and increasing circle/point size.
Now to label the maximum and minimum point on the sparklines - drag the Min or Max Points to the labels of the AGG(Min or Max points) marks card.