Google Sheets Sparkline Function Examples

The SPARKLINE function allows you to create miniature charts within a single cell to rapidly provide an attractive visual representation of data and trends. Google recently added the two new types - column and winloss - along with the existing line graph and bar chart.


When I am using Google Spreadsheets, I realized it wasn’t capable of displaying the data in the way that I wanted to. So I took another look at the Google Spreadsheet SPARKLINE function and found that, in many cases, they provide a more informative and much quicker visualization that charts. Once I got started, I figured I would exhaust the possibilities of the feature and share them here so that you can get started with them quickly and easily when you need to.

There are four different types of sparkline charts. I have a section for each:
  • Horizontal Bar Charts
  • Line Charts
  • Win/Loss Charts
  • Column Charts
  • Bonus: Use Hex Colors!

Horizontal Bar Charts

Single Series Data

Best for:  Comparing every cell in a column

Basic Bar Chart

=sparkline(A36,{"charttype","bar";"max",100})
It’s pretty straight forward. Make sure to set the max option so that the bar does not take up the full column.

Reverse Direction with Max Argument and Color

=sparkline(E42,{"charttype","bar";"color1","teal";"rtl",true; "max",max(C$36:C$44)})
rtl (right to left) changes the direction of the bars. Use the
max
function for the value of max with the data column as the range to set the width limit to the highest value in the data column.

Stacked Series Data

Best for:  Comparing multiple columns with each row as parts of whole

Stacked “Versus” Chart

=sparkline(E49:F49,{"charttype","bar";"color1","EB4967";"color2","73A4D3"})
Set color to hex codes for to make visually appealing sparklines. No value for max will set the width of the bar to the width of the cell.

Stacked Bar Chart

=sparkline(E58:H58,{"charttype","bar";"color1","A7DBD8";"color2","69D2E7";"max",max(I$58:I$61);"nan","ignore"})
The Q1 and Q2 values for the 2014 row do not have numerical values. Setting nan to “ignore” will exclude these values from the sparkline bar chart. The max option is set to the highest value of the Total column

Line Charts

Single Series (Y) Data

Best for:  Displaying time series data where value change over consistent time intervals

Standard Line Chart and the Effects of ymin

=SPARKLINE(B3:G3,{"charttype","line"; "color","indigo"; "linewidth",2})
=SPARKLINE(B3:G3,{"charttype","line";"color","indigo"; "ymin",0})
This chart uses a custom color and linewidth. It also demonstrates how to change the chart’s background color by changing the cell’s background color. Both charts display the same data, but because it sets the ymin option to 0, the chart looks much different. Be careful when setting limits and cell dimensions. These adjustments can make the data appear to say different things.

Line Chart with Conditional Coloring

=SPARKLINE(C7:H7,{"color",if(H7>C7,"green","red");"ymax",100; "linewidth",2})
The color is set to an if formula. This formula compares the first and last value of the series, and if the last value in the series is greater than the first value, the line color option is set to green; and if not, the color is set to red. The slope formula is also good for this, but it is better with X,Y series data.

Dual Series (X and Y) Data

Best for:  Displaying time series data where value change over inconsistent time intervals

Line Chart with Conditional Coloring

=SPARKLINE(C12:H13,{"color",if(slope(C13:H13,C12:H12)>0,"green","red"); "linewidth",2; "ymax",25; "xmax",15})
There is a lot going on here, but it builds on the previous example. The slope function is used to set the color for the line. If the slope is greater than 0 the line is green; else it is green. Additionally, ymax and xmax are set to values greater than any data value. This creates a margin around the line chart.

Line Drawing… Because you can

=SPARKLINE(C26:O27,{"color","red"; "linewidth",8})
Sparkline Line Drawing

The lines will follow the X and Y coordinates even if they are not consecutive. Go nuts!

COMMENTS

Name

ARRAY FORMULA,1,Budget Templates,1,Download Template,1,Essential Tips,1,Excel Template,1,Gantt Chart,1,Google Docs,1,Google Sheet,5,Google Sheet Add On,2,Google Sheet Formula,2,Google Sheets,8,Google Sheets Chart,1,Google Sheets Functions,3,Google Sheets Macro,1,Household Budget Templates,1,How to,11,keyboard shortcuts,1,Need to Know,1,Pivot Table,1,Tips and Tricks,6,
ltr
item
The Office Tricks: Google Sheets Sparkline Function Examples
Google Sheets Sparkline Function Examples
https://4.bp.blogspot.com/-zNzjswS7_ek/W6YX22_9McI/AAAAAAAAAEw/A5b3zTN3C7cT3E9feZDF-QNeNz6VRmStQCLcBGAs/s1600/sparklines-types.png
https://4.bp.blogspot.com/-zNzjswS7_ek/W6YX22_9McI/AAAAAAAAAEw/A5b3zTN3C7cT3E9feZDF-QNeNz6VRmStQCLcBGAs/s72-c/sparklines-types.png
The Office Tricks
https://theofficetricks.blogspot.com/2018/09/sparklines-in-google-sheets.html
https://theofficetricks.blogspot.com/
https://theofficetricks.blogspot.com/
https://theofficetricks.blogspot.com/2018/09/sparklines-in-google-sheets.html
true
2683631591702906538
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy