The Google Sheets SPARKLINE function draws a small chart inside a single cell: a line, columns, a progress bar or win-loss blocks. It is the quickest way to add a trend next to every row of a table. In Excel, the same idea lives on the Insert tab as Sparklines.
data |
The numbers to plot, such as B2:F2. |
|---|---|
options optional |
Settings in pairs inside curly brackets, such as {"charttype","column";"color","#188038"}. |
Basic line sparkline
One formula next to each row draws its trend:
=SPARKLINE(B2:F2)
Copy the formula down and every product gets its own five-month trend at a glance.
Column chart with a colour
=SPARKLINE(B2:F2, {"charttype","column"; "color","#188038"})
Each option is a pair: the setting name, a comma, its value, and a semicolon between pairs.
Options cheat sheet
| Option | Does | Works with |
|---|---|---|
"charttype" |
line, column, bar or winloss | all |
"color" |
Chart colour, by name or hex code | line, column, winloss |
"linewidth" |
Thickness of the line | line |
"highcolor" / "lowcolor" |
Colours the highest and lowest column | column, winloss |
"negcolor" |
Colour for negative values | column, winloss |
"ymin" / "ymax" |
Fixes the value axis | line, column |
"max", "color1", "color2" |
Scale and colours of the progress bar | bar |
Compare rows on the same scale
By default every sparkline scales to its own row, so a row of small numbers can look as dramatic as a big one. Fix the axis to compare rows fairly:
=SPARKLINE(B2:F2, {"charttype","column"; "ymin",0; "ymax",1000})A progress bar in a cell
The bar type turns a percentage into a progress bar. With 0.68 in B2:
=SPARKLINE(B2, {"charttype","bar"; "max",1; "color1","#188038"})Notes
- The chart fills the cell, so make it bigger by widening the column or the row, and style the cell itself for a background.
- SPARKLINE works with other functions as data:
=SPARKLINE(GOOGLEFINANCE("NSE:INFY","price",TODAY()-30,TODAY(),"DAILY"))draws a 30-day price trend. - winloss only shows whether each value is positive or negative: handy for match results or daily gain/loss.
Common errors
- Formula parse error: a typo in the options. Check the quotes, the comma inside each pair and the semicolon between pairs. In some locales the pairs are separated with
\instead of a comma. - #N/A: the data range has no numbers to plot.
- A flat line: all values are equal, or ymin/ymax are set too wide.
Frequently asked questions
Can the colour change based on the values?
For columns, yes: use highcolor, lowcolor and negcolor. A line sparkline has a single colour.
Can I make a sparkline bigger?
Yes. The chart fills its cell, so increase the row height and column width, or merge cells before adding the formula.
Do sparklines print and export?
Yes. They print with the sheet and appear in PDF exports, because they are drawn inside the cell.
How do I delete a sparkline?
Delete the formula in the cell. There is no separate chart object to remove.