Everything you ever wanted to know about Sparklines in Google Sheets


  1. Introduction
  2. Sparkline Examples
  3. Sparkline Syntax
  4. Line Sparklines
  5. Column Sparklines
  6. Bar Sparklines
  7. Winloss Sparklines
  8. Option/value pairs in cells
  9. More advanced examples
  10. Sparkline issues
  11. Further reading


Sparklines are small, lightweight charts, typically without axes, which exist inside a single cell in your spreadsheets. They’re a wonderful, quick way to visualize your data, without needing the complexity of a full-blown chart.

They were first created by interface designer Peter Zelchenko around 1998. The term “sparkline” was coined by statistician and data visualization legend Edward Tufte.

Sparkline examples

I’ve been building a lot of dashboards in Google Sheets recently, making heavy use of sparklines to show data trends.

For example, here’s a column sparkline to show website users in the past 30 days:

Column sparkline example

Then, a combination of line sparklines and bar sparklines for social media metrics:

Line sparkline example

And finally, I’ve used a winloss sparkline chart to show web outages over the past 24 hour period:

Winloss sparkline example

So let’s explore how to create these charts and customize them to meet your needs. Links to all of the examples below are available for viewing in Google Sheets.

Sparkline Syntax

The most basic sparkline in Google Sheets looks like this:


Assuming your data is in range A1 to A8, the formula would be:


See this example live in this Google Sheet.

More generally, the sparkline formula syntax is:


This refers to the dataset (the range of values) you want to plot as a sparkline.

This is an optional argument, used to specify things like chart type (e.g. column), color and other specific settings:

  • Conditions are placed inside a set of curly braces { ... }
  • Options are further enclosed in double quotes, e.g. "charttype"
  • Option values are usually enclosed in double quotes, e.g. "column" but numbers or true/false settings do not need the double quotes
  • Options and values are separated by commas
  • Multiple options/value pairs are separated by semi-colons

Example: {"charttype","column";"axis",true;"axiscolor","red"}

We’ll explore all of this below.

There are four types of sparkline charts available in Google Sheets: line charts (the default), column charts, bar charts and winloss charts.

Let’s take a look at each in turn, through a series of examples.

Line sparklines

Link to live Google Sheet with all of these examples.

This is the default choice for sparklines in Google Sheets, meaning that Google will default to showing a line if you don’t specify anything in your options.

Assume I have the following data in columns A and B of my Google Sheet. The idea here is to create a sparkline that displays the sales data from column B in a single cell, as a simple, lightweight chart without any additional details.

Sparkline line data

You’ll notice there are some blank values, some negative values and some text values in column B. That’s intentional and we’ll explore how to deal with each of those with the sparkline formula.


Since line charts are the default sparkline option, we don’t need to explicitly specify the chart type. So we can create a sparkline line chart with this simple formula:


sparkline line

Color option:

Change the color of your sparkline by adding the color option/value pair, as follows:


or using hex notation:


Sparkline color line

Line-width option:

The higher the number you specify, the thicker the line.


Sparkline line width

Xmax and Xmin options:

If our data includes a column of x-values, then we can then specify a minimum or maximum for that axis. So from our data above, we now include column A in our spakrline formula argument, then specify a minimum and/or maximum in our sparkline options, for example:


This would only include values from column B, where the values in column A are between 5 and 15.

Note: I would advise a degree of caution with the xmin and xmax criteria. They are somewhat volatile and caused one of my Google Sheets to repeatedly crash.

Ymax and Ymin options:

Similarly we can specify bounds on the y values we plot in our sparkline, by using the ymax or ymin criteria. For example to only include values zero or above we would use:


To set a ymax and ymin:


Empty option:

Use the “empty” option to determine whether blank cells in your dataset are rendered as 0 in your sparkline, or just ignored (the datapoint is not included in your sparkline). The formulas are respectively:



Nan option:

Similar to the empty option above, use the “nan” option to determine how non-numeric cells (text cells) in your dataset are rendered in your sparkline. The options here are to convert to 0 or to ignore, as above, and the formulas are respectively:



Rtl option:

Want your chart to show from right-to-left? Use the option “rtl”, which can be set to true or false, to specify the direction of your sparkline.


Sparkline rtl

Compare this sparkline to the first line chart and you’ll see the reversed direction:

sparkline line

Column sparklines

Link to live Google Sheet with all of these examples.

As the name suggests, column sparklines are small column charts that exist inside a single cell. For these examples, I’m using data set up as per the line chart example.

Default option:


Sparkline column chart

Color option:


Sparkline column chart

Lowcolor option:


Sparkline column chart

Highcolor option:


Sparkline column chart

Firstcolor and lastcolor options:


Sparkline column chart

Similarly, you can se the lastcolor option.

Negcolor option:


Sparkline column chart

Axis and Axiscolor options:


Sparkline column chart

Ymax and Ymin options:

Works the same as the line chart examples above. For example, setting a max value of 0 creates a sparkline with only the negative columns showing:


Sparkline column chart

Empty option:

Works the same as the line chart examples above.

Nan option:

Works the same as the line chart examples above.

Rtl option:

Works the same as the line chart examples above.

Bar sparklines

Link to live Google Sheet with all of these examples.

You guessed it, these are small bar charts that exist inside a single cell. The usage is a little different than the line and column charts we’ve looked at so far though, because these are stacked bar charts. So you can point to a single cell of data and create charts based off of that, for example.

Using multiple bar sparklines to create charts:

This method works by setting a max value that applies to all your bar sparklines, using the “max” option. So step 1 is to determine a suitable maximum that works for your whole data range (consider using the MAX() formula to determine). In this example, 30 worked as my max option.

The formulas to create these sparklines are:


Sparkline bar chart

Two series:


Sparkline bar chart

Two series with as stacked percentage chart:


Sparkline bar chart

Two series with as stacked bar chart:

Using the sum of the two values as the “max” option ensures that the bars will always be 100% of your cell width.


Sparkline bar chart

Changing colors:

You can specify up to two colors in sparkline bar charts. The colors alternate for each new value.


Sparkline bar chart

Other options:

Sparkline bar chart

The formulas to create these bar sparklines, in the order they appear above, are:


=sparkline($B46:$D46,{"charttype","bar";"max",30;"color1","#009900";"color2","#66ff66"; "empty","zero"})

=sparkline($B47:$D47,{"charttype","bar";"max",30;"color1","#009900";"color2","#66ff66"; "empty","ignore"})

=sparkline($B48:$D48,{"charttype","bar";"max",30;"color1","#009900";"color2","#66ff66"; "nan","convert"})

=sparkline($B49:$D49,{"charttype","bar";"max",30;"color1","#009900";"color2","#66ff66"; "nan","ignore"})

=sparkline($B50:$D50,{"charttype","bar";"max",30;"color1","#009900";"color2","#66ff66"; "rtl",true})

Winloss charts

Link to live Google Sheet with all of these examples.

These are a special type of column chart that plots only 2 possible outcomes: positive and negative (e.g. like a coin toss, heads or tails).

Here’s the dataset for the following examples. The winloss sparkline is only concerned with whether a datapoint is positive or negative, it doesn’t take relative sizes into account. So, in effect, it’s really like a column chart of -1’s and 1’s.

Winloss sparkline data

Default winloss sparkline:


Sparkline winloss chart

Color option:


Sparkline winloss chart

Lowcolor/Highcolor option:

Even though the winloss chart displays all the “columns” the same height, it is able to highlight the highest and lowest values in your original dataset. For example, the following formula colors the lowest values red (in the case of this dataset, that’s the three -10 values):


Sparkline winloss chart

Firstcolor option:

Highlights the first value of the dataset:


Sparkline winloss chart

Lastcolor option:


Sparkline winloss chart

Negcolor option:

Highlights all the negative values:


Sparkline winloss chart

Axis and Axiscolor options:

=SPARKLINE($B$2:$B$21,{"charttype","winloss";"axis",true; "axiscolor","red"})

Sparkline winloss chart

Empty option:

Works the same as the line chart examples above.

Nan option:

Works the same as the line chart examples above.

Rtl option:

Works the same as the line chart examples above.

Option/value pairs in cells

Link to live Google Sheet with all of these examples.

So far, we’ve encoded the options as an array of text strings inside of the sparkline formula, between the curly braces, e.g.: {"charttype","column";"axis",true;"axiscolor","red"}

However, we can instead list our option/value pairs in a range of cells in our spreadsheet, and then reference them in the sparkline formula.

Consider a dataset and option/value pairs setup as follows:

Sparkline options in cell

Then enter this formula into cell F2:


to create your sparkline. We still need to enclose the options in the curly braces, { ... }, and separate the options and values with commas and semi-colons, but notice how we’ve used cell references instead of text strings this time.

The output of this formula is the following sparkline, in cell F2:

Sparkline column

We can take this even further by putting all our options into two columns and then referencing those ranges:

Sparkline options in cell

The formula in this case is then:


where my range of option/value pairs extend down to row 9 (adjust as needed to accommodate different number of options).

Lastly, we could get fancy by adding a data validation drop down menu to pick from the option/value pairs, e.g. for charttype, as shown in the following GIF:

sparkline data validation

More advanced sparkline examples

Link to live Google Sheet with all of these examples.

You can nest other formulas inside of sparklines, for example you can quickly and easily plot stock prices using the sparkline formula.

Let’s create sparklines for the big tech stocks in 2016, like so:

Sparkline stock prices

We create these charts by first using the GOOGLEFINANCE() function to get the stock prices from January 1, 2016 (using the DATE() formula) to today (using the TODAY() formula):


Then we nest this inside the sparkline formula to chart this data:


Cool huh!

We can also turn this same data into column charts, but we need to finesse the GOOGLEFINANCE data since we only want the second column of data. We do this with the QUERY() function:

=query(GOOGLEFINANCE($B13,"price",DATE(2016,1,1),TODAY(),"DAILY"),"select Col2",-1)

Then we nest this inside the sparkline formula:

=sparkline(query(GOOGLEFINANCE($B13,"price",DATE(2016,1,1),TODAY(),"DAILY"),"select Col2",-1),{"charttype","column";"highcolor","red"})

I’ve also highlighted the highest stock price in our period, using red shading. The output is as follows:

Sparkline stock prices

Sparkline Issues:

I’ve come across two issues using sparklines, one of which I mentioned above.

Issue 1

Using the xmin and xmax options together in a line chart caused Google Sheets to repeatedly crash.

This formula:


caused this issue:

Sparkline crashing Google Sheets

Issue 2

If you publish your Google Sheet to the web, then your sparklines will disappear unfortunately!

I’ve reported both these issues to the Google support team so I’ll keep you posted if there are any updates.

Further reading

Official Google Documentation.
Sparklines on Wikipedia.
Edward Tufte’s detailed take on sparklines.
Sparklines can be implemented in Microsoft Excel too.

28 thoughts on “Everything you ever wanted to know about Sparklines in Google Sheets”

  1. Hi Ben,

    I wonder if sparklines can be used to show the distribution of data. I find myself in many situations in which I’m looking at really basic statistics, but I may be missing out on the real data by looking at the distribution of data.

    If I could easily see where there’s some significant normal or chi distribution, I would save time doing graphs one by one and straigh away see where there are interesting things to dig into!

    Any ideas?

  2. Hi Ben

    Really useful.

    Can a series show “highcolor” and “lowcolor” at the same time? I’m looking to use both with this formula.

    Regards – Nigel.

    sparkline(query(GOOGLEFINANCE($A$5,”price”,DATE(2016,1,1),TODAY(),”DAILY”),”select Col2″,-1),{“charttype”,”column”;”highcolor”,”red”})

    1. Hi Nigel, you can add the lowcolor option after the highcolor, like so:

      =sparkline(query(GOOGLEFINANCE($A$5,”price”,DATE(2016,1,1),TODAY(),”DAILY”),”select Col2″,-1),{“charttype”,”column”;”highcolor”,”red”;"lowcolor","orange"})

      However, you probably won’t be able to see the lowcolor on your sparkline, because it’s so close to the axis as to be invisible. If you try with a smaller date range, you should be able to see the effect, e.g. last week prices for Google ticker:

      =sparkline(query(GOOGLEFINANCE("GOOG","price",today()-7,today(),"DAILY"),"select Col2 offset 1"),{"charttype","column";"highcolor","red";"lowcolor","orange"})

      Hope that helps!


  3. =SPARKLINE(I3:K3,{“linewidth”,3})

    I can´t understand why it is not working in my spreadsheet.

    When I create the sparkline above it shows me an #ERRO!

      1. Hi Renato, Not sure why that’s not working for you. I’ve just tried:
        and it works for me in my Google Sheet. Feel free to share the sheet if you want.


      1. Great suggestion Stefan, thanks! The use of comma’s or semi colons as separators in your formulas depends on your locale. Hopefully this fixes the issue for you.

  4. Hi Ben,
    Is it possible to highlight/color out of range values? Like for a specified max or min value (sort of like highcolor and lowcolor will do, but for as many high or low values outside of a certain range as are in the data)?
    I’m thinking of charting lab results, where a “normal” range is expected and I’d like to highlight higher or lower than normal values. Could be in a line or column sparkline.

    1. Hi Saro,

      Unfortunately you can’t get to this level of detail with the line or column sparklines.

      The closest I could get was with bar sparklines to highlight values above a threshold: https://docs.google.com/spreadsheets/d/1zKlMFfI6-K9RywMze-emK0VquerUnsHoQ9JpSA-V9IE/edit?usp=sharing

      Sparklines are really designed for “at-a-glance” type reading so they’re not best suited to really detailed charts. You might be better plotting with a regular stacked column chart.


      1. Hi Ben,

        Thanks for responding. I actually found a very clunky workaround that involves plotting the normal range values (max and min) as extreme datapoints, and then using xmin and xmax to hide them from the sparkline view. That way, I get two horizontal lines at the normal maximum and normal minimum, which will work for what I’m doing. Example is here: https://docs.google.com/spreadsheets/d/1IsYuFgQJxeUFQK-ynuQBeHbpifhb8qlCqyLwglKF0RI/edit?usp=sharing

        But I really like the stacked columns/bars idea, and might play with that too if I decide the colors would be easier to see that way. I just want an at a glance indicator if something was out of the expected range.


        1. Great work Saro and thanks for sharing your worksheet! I hadn’t thought of using an array as the data for the sparkline, really interesting. I’ll have to update this post to deal with input arrays at some stage…

  5. Is it possible to create a sparkline in googlesheets with multiple ranges? I’m trying to create a cell-based column chart that does not use consecutive data (though all in the same row). If so, is there also a way to filter out certain columns based on the column headers?


    1. Hey Amy,

      Yes, you can do that. After some experimentation I found using the filter function with an Array Formula will do the trick. The trick is to create an array of TRUE/FALSE corresponding to the columns you want to include/exclude. You can do this with a helper row (which has the advantage of being able to change the column selection easily) or by coding TRUE/FALSE directly in the formula.

      For example, if I had data in columns B to J and I want to include only columns B,C,F,G,H,J then I can use either of these formulas:



      Here’s an image of the sheet and formula: Sparklines with array formulas

      Here’s a spreadsheet showing these formulas. Feel free to make a copy.

      Hope that helps.


      1. Ben, thanks so much for your quick and thorough reply! (And for being a genius!)

        The column headers in my spreadsheet are selected from drop-down lists, so I’m using your first suggestion (the helper row) and it’s working perfectly. All I needed was an =IF formula based on the column headers to generate the helper row.

        Greatly appreciated!


  6. Hi Ben,

    I just started customizing Eric Bates’ highly recommended project management template (http://eric-bates.com/project-planning-template/) and wanted to find out more about sparklines. I was happy to find your very clear guide on how to use and adapt them — btw, your page is the second search result for “sparklines Google sheets” — First is Google support 🙂

    Happy too to see a compatriot making it in DC. ╭( ・ㅂ・)و ̑̑

  7. Hi
    Do you know how to create a sparkline in Google sheets that automatically updates based on last value in a column? For example if I have a column of data from A10 to AXX, where XX constantly changes, how do I create sparkline for this?

    1. Sure thing! There’s a couple of ways to do this, one easy and one that involves some more advanced formulas but is rather crafty 😉 (there are probably/possibly other ways too).

      1. Simply use the range A10:A in your sparkline formula, so it looks like this:

      Basic sparkline with dynamic range

      2. Use a formula to find the last cell in the column that is non-blank, create a string from that, create a named range for the cell with the string, use the indirect formula to refer to this string range inside your sparkline formula! Oooof, definitely harder!

      Sparkline with dynamic range using indirect formula

      Here’s the sheet with both examples.

      Feel free to make your own copy and then you can try it out.


  8. Hi Ben!

    Tx a lot for this article, it’s really helping me, i just wanna ask you one quesiton, because i was unable to do it in G spreadsheets.

    I have an excel spreadsheet that i want to convert to GSpreadsheet, in the excel i have the following bar chart: (check the screenshot, pls)

    The thing is that i can’t figure it out how to display the negatives value, as in excel. There is any way to do it, or i need to go with a column chart type?

    tx, Bruno!

    1. Hey Bruno,

      Yes, you can get pretty close (minus the data labels) by using the Right-to-Left feature of bar sparklines. I use an IF formula to see if I have a positive or negative value, then choose the sparkline accordingly. Here’s the formula:


      which will create sparklines like this:

      Negative bar sparklines

      Here’s a google sheet example: https://docs.google.com/spreadsheets/d/1lZJBFvjy6zmKQ7FTGioeft28VpPjekzAYg-fJXXq0II/edit?usp=sharing

      Hope that helps.


Leave a Reply

Your email address will not be published. Required fields are marked *