Google Sheets function · Google-only
SPARKLINE in Google Sheets: syntax and examples
SPARKLINE draws a small chart inside a single cell from a range of values. The optional second argument is a two-column array of option names and values, such as charttype, color, max and linewidth. The cell has no value of its own, so other formulas cannot read it.
Syntax
SPARKLINE(data, [options])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
data | range | yes | The values to draw: a range, or a single cell for bar charts. |
options | array | no | A two-column array of option name and value pairs, such as {"charttype","column"}. |
Examples
The examples use this table, starting in A1:
| Month | Sales | Target | Change |
| Jan | 40 | 50 | 5 |
| Feb | 55 | 50 | -3 |
| Mar | 35 | 50 | -8 |
| Apr | 70 | 50 | 12 |
| May | 65 | 50 | -2 |
=SPARKLINE(B2:B6)Result:
A line chart of five values, drawn inside the cell.
Run in a Google Sheet (English US locale) on .
=SPARKLINE(B2:B6, {"charttype", "column"})Result:
Same data as columns.
Run in a Google Sheet (English US locale) on .
=SPARKLINE(B2, {"charttype", "bar"; "max", 100; "color1", "green"})Result:
One cell as a progress bar: 40 out of a maximum of 100.
Run in a Google Sheet (English US locale) on .
=SPARKLINE(D2:D6, {"charttype", "winloss"; "negcolor", "red"})Result:
Win-loss chart: positive values up, negative values down in red.
Run in a Google Sheet (English US locale) on .
=SPARKLINE(B2:B6, {"linewidth", 3; "color", "blue"; "ymin", 0})Result:
Thicker blue line, with the vertical axis starting at zero.
Run in a Google Sheet (English US locale) on .
Common errors
- Options go in as an array of name and value pairs: {"charttype","column"}. A plain string like "column" returns #REF!.
- charttype accepts line, bar, column and winloss. Any other word, such as pie, returns #VALUE!.
- The cell shows a picture, not a number. It cannot be combined with other values: SPARKLINE(B2:B6)&"x" returns #VALUE!.
- In a ro_RO file, write the options array with \ between name and value and ; between pairs. Commas, as in English tutorials, fail.
Compared with Excel
SPARKLINE exists only in Google Sheets. Excel has sparklines as a ribbon feature, not as a formula.
Questions and answers
Can SPARKLINE show a progress bar from a percentage?
Yes. Point it at one cell and set {"charttype","bar";"max",1}.