Back to Functions

SPARKLINE

Creates a miniature chart contained within a single cell.

GoogleSPARKLINE(data, [options])

SPARKLINE draws a small chart inside a single cell: a line, a set of columns, a progress bar or a win/loss strip. It gives a dashboard or a data table an instant visual summary of trends, progress and comparisons, without a full chart.

Syntax

=SPARKLINE(data, [options])
  • data: A row or column of values (or a single value for a bar). The chart is drawn from these numbers.
  • options [Optional]: Settings for the chart, given as pairs of "name", value inside curly braces, such as {"charttype", "column"; "color", "blue"}. Separate pairs with a semicolon.

The chart fills the cell, so a wider and taller cell makes a more readable chart.

Chart types

Set "charttype" to one of:

  • "line" (default): a trend line
  • "column": vertical bars
  • "bar": a single horizontal bar, mainly for progress and proportions
  • "winloss": a strip of up and down blocks for positive and negative values

Line

=SPARKLINE(B2:G2)

A trend line through six values.

=SPARKLINE(B2:G2, {"charttype", "line"; "color", "#1a73e8"; "linewidth", 2})

Column

=SPARKLINE(B2:G2, {"charttype", "column"; "color", "teal"; "highcolor", "green"; "lowcolor", "red"})

Columns, with the highest bar in green and the lowest in red.

Bar: a progress meter

=SPARKLINE(B2, {"charttype", "bar"; "max", 100; "color1", "green"})

A bar that fills in proportion to the value in B2 out of a maximum of 100. Add "color2" to color the unfilled part.

For two segments, such as completed and remaining, pass both values:

=SPARKLINE({B2, C2}, {"charttype", "bar"; "color1", "green"; "color2", "lightgray"})

Win/loss

=SPARKLINE(B2:G2, {"charttype", "winloss"; "color", "green"; "negcolor", "red"})

Positive values draw blocks above the axis, negative values below.

Options reference

Common options (not every option works for every chart type):

  • "color": the line or bar color. Names such as "red", or hex codes such as "#1a73e8".
  • "linewidth": the line thickness, such as 2.
  • "ymin", "ymax": the vertical axis range. Fixing these makes different sparklines comparable.
  • "xmin", "xmax": the horizontal range.
  • "max": the maximum for a bar chart, such as 100.
  • "highcolor", "lowcolor": colors for the highest and lowest columns or points.
  • "firstcolor", "lastcolor": colors for the first and last columns or points.
  • "negcolor": the color for negative values in column and win/loss charts.
  • "axis": TRUE draws the horizontal axis, with "axiscolor" to set its color.
  • "rtl": TRUE draws the chart right to left.
  • "empty": how empty cells are handled: "zero" or "ignore".
  • "nan": how non-numeric text is handled: "convert" or "ignore".
  • "color1", "color2": the two segment colors for bar charts.

Practical patterns

Trend column next to a table of months

With months across B2:M2, add a sparkline in N2 and copy it down:

=SPARKLINE(B2:M2, {"charttype", "line"; "color", "#1a73e8"})

Each row now gets its own mini trend.

Compare rows on the same scale

Sparklines scale to each row's own data by default. To compare rows fairly, fix the axis:

=SPARKLINE(B2:M2, {"charttype", "column"; "ymin", 0; "ymax", 1000})

Progress to goal

=SPARKLINE(C2 / D2, {"charttype", "bar"; "max", 1; "color1", IF(C2 / D2 >= 1, "green", "orange")})

A bar that shows how much of the goal in D2 is reached by the value in C2, colored green when complete.

Stock price history

=SPARKLINE(GOOGLEFINANCE("NASDAQ:GOOG", "close", TODAY() - 90, TODAY()), {"charttype", "line"})

This is the standard way to get a price trend into a single cell.

Fill the whole column

SPARKLINE returns one chart per cell and does not spill. Enter the formula in the first row and drag it down (or double-click the fill handle).

Common errors

  • A blank cell. The data range is empty or contains only text. Check that data points to numbers.
  • #VALUE!/#ERROR! with options. A bracket or quote is missing, or an option name is misspelled. The options are a single set of curly braces with pairs separated by semicolons: {"name1", value1; "name2", value2}.
  • A flat or odd-looking line. The data has text or blanks. Use "empty", "ignore", or clean the data. Also check the axis range.
  • Tiny or unreadable chart. The cell is too small. Widen the column and increase the row height.
  • Colors not applied. The option isn't supported for that chart type. For example, "highcolor" applies to column charts and "color1" to bar charts.

SPARKLINE vs. full charts

A full chart (Insert > Chart) can show axes, legends and many series, which is best for presentation. A sparkline is a single series with no labels, designed to sit next to the numbers and to repeat down a table. Use sparklines to scan many rows at a glance, and charts for detail.

Frequently asked questions

Can I add labels or values to a sparkline? No. It is a bare chart. Place the numbers in adjacent cells.

Can I change the sparkline when the data changes? Yes, it updates automatically with the underlying data.

Can a sparkline use data from another sheet? Yes: =SPARKLINE(Data!B2:M2).

Does it work with a column of values? Yes, a row or a column both work.

Related Functions

  • GOOGLEFINANCE: Fetch stock and currency data.
  • QUERY: Select the data for a sparkline.
  • IF: Choose colors conditionally.
  • INDEX: Pick a range from a table.
  • ARRAYFORMULA: Apply a formula to a whole range.

Related Articles

Newsletter

More SPARKLINE examples coming soon.

We are building short, practical updates for Sheets power users.