Skip to main content
More Menu
Reading ListGanti ke TerangSearch
Reading List

Queue · 0 items

Your reading list is empty. Save articles to read them later.

Start Reading
ESCto close
↑↓to navigate

Google Sheets SPARKLINE: In-Cell Mini Charts in One Formula

SheetHub8 min
The Google Sheets SPARKLINE function draws a mini chart inside a single cell. You don't need a chart editor. You have a row of monthly sales figures. The numbers are clear, but the trend isn't. You don't want to build a full chart — you just want a tiny visual cue next to each row so you can scan the data at a glance. Enter SPARKLINE: a chart you can drop into any cell. SPARKLINE creates these mini charts with a single formula. Type the formula, and your cell turns into a chart.

What Is SPARKLINE?

SPARKLINE is a Google Sheets formula that turns one row of data into a visual trend, comparison bar, or win/loss indicator. Unlike Excel sparklines (which are chart objects attached to cells), Google Sheets SPARKLINE is a formula. This means:
  • It moves with your data when you sort or filter
  • It recalculates automatically when source data changes
  • You can copy it down a column to create one sparkline per row
  • You can copy and paste it like any other formula
SPARKLINE supports four chart types: LINE, BAR, COLUMN, and WINLOSS.

SPARKLINE Syntax

=SPARKLINE(data, [options])
  • data — A range or array of values to chart
  • options (optional) — A set of key-value pairs for customization
The simplest possible sparkline:
=SPARKLINE(B2:G2)
This creates a default line chart from the six values in row 2. That's it. One formula, one in-cell chart.

Chart Types and Customization

LINE Chart

The default type, best for showing trends over time:
=SPARKLINE(B2:G2, {"charttype", "line"; "linewidth", 2; "color", "blue"})
Locale Syntax Note
The options array uses commas and semicolons: within each key-value pair, a comma separates the key from the value, and a semicolon separates one pair from the next. If your spreadsheet is set to a non-US locale (for example, many European regional settings), Google Sheets may expect these separators swapped — semicolon inside the pair and comma between pairs. If SPARKLINE throws a parse error, try the reversed form: {"charttype"; "line", "linewidth"; 2, "color"; "blue"}.
OptionEffect
linewidthThickness of the line (1-5)
colorLine color (name or hex)

BAR Chart

Horizontal bars, good for comparing values side by side:
=SPARKLINE(B2:G2, {"charttype", "bar"; "max", 100; "color1", "green"; "color2", "red"})
BAR charts are useful for budget variance — actual vs target in a single cell.

COLUMN Chart

Vertical bars — like a mini bar chart:
=SPARKLINE(B2:G2, {"charttype", "column"; "color", "#4285F4"; "negcolor", "red"})

WINLOSS Chart

Up/down indicators for binary outcomes — winning streaks, project milestones, or pass/fail tracking:
=SPARKLINE(B2:G2, {"charttype", "winloss"; "color", "green"; "negcolor", "red"})
Each value above zero gets a green bar, below zero a red bar. Perfect for tracking streaks.

SPARKLINE + GOOGLEFINANCE — Live Stock Visuals

This is where SPARKLINE shines. Combine it with GOOGLEFINANCE to create live stock performance charts inside a single cell:
=SPARKLINE(GOOGLEFINANCE("AAPL", "close", TODAY()-30, TODAY()))
This shows Apple's 30-day stock price trend as a mini line chart. Every time you open the sheet, it refreshes with the latest data. Customize it for a bullish look:
=SPARKLINE(GOOGLEFINANCE("AAPL", "close", TODAY()-30, TODAY()),
  {"charttype", "line"; "linewidth", 2; "color", "#00AA00"})
For a full portfolio view, combine SPARKLINE with GOOGLEFINANCE for live stock mini-charts across every ticker in your portfolio. Live stocks are just the start. Point SPARKLINE at your own data and it does the same job.

Practical Applications

Use CaseFormula Pattern
Sales trend per product row=SPARKLINE(B2:G2)
Budget variance bar=SPARKLINE({actual, budget}, {"charttype", "bar"})
KPI dashboard with 100+ rows=BYROW(B2:G100, LAMBDA(row, SPARKLINE(row)))
Project win/loss tracker=SPARKLINE(B2:G2, {"charttype", "winloss"})
Stock performance sparkline=SPARKLINE(GOOGLEFINANCE(A2,"close",TODAY()-30,TODAY()))
For large dashboards, apply formulas across hundreds of rows with ARRAYFORMULA — just remember SPARKLINE charts one row per formula, so copy the formula down instead. SPARKLINE mini-charts also work as building blocks in Canvas dashboards, providing lightweight visual cues alongside interactive components.

KPI Dashboard Example

ProductJanFebMarAprMayJunTrend
Widget A120135128142155148=SPARKLINE(B2:G2)
Widget B90859510298110=SPARKLINE(B3:G3)
Widget C200210195205220230=SPARKLINE(B4:G4)
The Trend column shows each product's sales trajectory instantly. Widget B dips in Feb but recovers. Widget C is consistently growing. You can scan 50 rows in seconds — that's the power of SPARKLINE.

SPARKLINE Options Reference

OptionValuesDescriptionApplies To
charttypeline, bar, column, winlossType of sparklineAll
colorColor name or hex codeMain chart colorAll
negcolorColor name or hex codeColor for negative valuesAll
linewidthNumber (1-5)Line stroke thicknessLINE
maxNumberMaximum value for axis scaleBAR, COLUMN
xmin / xmaxNumberX-axis rangeLINE
axisBoolean or colorShow/hide axis lineLINE
color1 / color2ColorFirst/second bar colorBAR

Limitations

SPARKLINE is lightweight by design, which means some tradeoffs:
  • One row of data per sparkline — no multi-series charts in a single cell
  • No labels or axis titles — the chart lives inside the cell, so there's no room for text
  • No interactive elements — hover, tooltip, and click don't exist
  • Options syntax can be confusing — the nested array format takes some getting used to
If you need full-featured charts with labels, legends, and interactivity, use Google Sheets' chart editor or Canvas dashboards instead.

SPARKLINE in Excel vs Google Sheets

If you're coming from Excel, SPARKLINE works differently than you might expect:
FeatureGoogle Sheets SPARKLINEExcel Sparkline
TypeFormula (=SPARKLINE())Chart object (ribbon)
CustomizationFormula options in cellRibbon + Format pane
PortabilityFormula moves with dataTied to cell position
Copy/pasteWorks like any formulaRequires special handling
WINLOSS type✅ Supported✅ Supported
The formula-based approach in Google Sheets is more flexible — you can nest SPARKLINE inside IF statements or combine it with GOOGLEFINANCE in ways Excel's chart-based sparklines can't match.

Common Errors and Troubleshooting

#VALUE! — empty or invalid data range. SPARKLINE needs at least one numeric value. A blank range, a text-only range, or a single empty cell returns #VALUE!. A numeric range like =SPARKLINE(B2:G2) works fine; a single empty cell like =SPARKLINE(A1) does not:
=SPARKLINE(B2:G2)
Parse error in the options array. The options argument must be a valid array literal. A typo in the separator — or the wrong separator for your locale — breaks the whole formula. If you see a parse error, check the separators against the Locale Syntax Note above. #N/A — errors inside the data. If the source range contains #N/A or another error value, the sparkline fails. Clean the data first, or neutralize errors with IFERROR:
=SPARKLINE(ARRAYFORMULA(IFERROR(B2:G2, 0)))
#NAME? — misspelled function name. A typo like =SPARKLIN(B2:G2) returns #NAME?. Also remember the formula is Google Sheets-only — the Excel equivalent is a chart object on the Insert tab, not a formula.

AI Prompt Callout

Now that you understand SPARKLINE syntax and options, here's how to describe your visualization needs to an AI assistant (ChatGPT, Gemini, or Claude):
AI Prompt Template
I have monthly sales data for 20 products across columns B through G (one row per product). I want a SPARKLINE next to each product's data showing the sales trend with a blue line. Write a SPARKLINE formula I can copy down for each product row, plus a BYROW version if possible.
The AI will generate the formula based on the examples above — just adjust the range to fit your data.

SheetHub's Take

SPARKLINE turns cells into live data visualizations with a single formula. Everything happens inside the formula bar:
  • LINE sparklines for trends over time
  • BAR and COLUMN for comparisons
  • WINLOSS for binary tracking
  • Combine with GOOGLEFINANCE for live stock charts
  • Copy SPARKLINE down a column to scale across hundreds of rows
Pick a row of data in your sheet and type =SPARKLINE(B2:G2). You just made your first in-cell chart. Now imagine doing that for every row in your dashboard.
Topics

Topics in this article

Explore related topics and continue reading similar content.

Share this article

Discussion

Preparing the comments area...

You Might Also Like