The Google Sheets sparkline formula is =SPARKLINE(data, [options]), where data is a range of numbers and [options] is an optional set of configuration values. For example, =SPARKLINE(A2:A10) creates a simple line chart inside a single cell, letting you visualize trends without a full chart object.
What Is a Sparkline and Why Use It?
A sparkline is a miniature chart that fits inside one cell, designed to show a data trend at a glance. Unlike a regular chart that sits on top of the grid, a sparkline is part of the cell content, so it moves, sorts, and filters with your data. This makes it ideal for dashboards, financial reports, or any sheet where you need to compare many series without cluttering the view.
Google Sheets supports four types of sparklines: line, bar, column, and win/loss. The type is controlled by the charttype option. Each type serves a different purpose: line for trends over time, bar for horizontal comparisons, column for vertical comparisons, and win/loss for binary outcomes (like wins vs. losses).
How the SPARKLINE Formula Works
The formula requires at least one argument: the data range. The optional second argument is a set of options written as a named array or as key-value pairs. In Google Sheets, you write options using the format {"option1", value1; "option2", value2}.
Here is the basic syntax breakdown:
data– a range likeA2:A20or an array of numbers.options– a semicolon-separated list of key-value pairs, each pair separated by a comma. Keys are text strings in quotes.
Example with options: =SPARKLINE(A2:A20, {"charttype","line"; "linewidth",2; "color","#4285f4"}) creates a blue line sparkline with a thicker line.
How to Choose the Right Chart Type
Selecting the correct charttype is the most important decision. Here is a practical guide:
- Line – best for continuous data, like daily sales or temperature over time. It highlights trends and patterns.
- Bar – best for comparing values across categories, like product sales. Each bar represents one data point.
- Column – best for showing changes over discrete periods, like monthly revenue. Similar to a bar chart but vertical.
- Win/Loss – best for binary data, such as whether a target was met (1) or not (-1). It shows only positive/negative bars.
For most general-purpose use, line is the default and works well. If your data includes negative numbers, the win/loss type handles those naturally, but line and column also support negatives.
Common Problems and How to Fix Them
Several issues frequently confuse users. Here are the most common and their solutions:
- Sparkline not showing – Check that the data range contains numeric values only. Text or empty cells can cause errors. Also, ensure the formula is entered correctly with an equals sign.
- Only a blank cell appears – If the range is empty or all values are identical, the sparkline may render as a flat line that is hard to see. Try adding a color or increasing the line width.
- Error: Function SPARKLINE parameter 1 expects number values – This means the data range contains non-numeric entries. Clean your data or use
=SPARKLINE(TOCOL(A2:A10,1))to filter out errors and text (TOCOL is available in newer versions). - Sparkline is too small to read – Adjust the row height or column width. You can also increase the line width or bar thickness using options like
"linewidth"or"barwidth". - Want to show a different color for max/min – Use options like
"highcolor"and"lowcolor"to highlight extremes.
SPARKLINE vs. Regular Charts in Google Sheets
Regular charts (Insert > Chart) offer far more customization: axis labels, legends, gridlines, and many chart types. They are separate objects that float over the grid. Sparklines, in contrast, are cell-bound, lightweight, and update automatically when the underlying data changes. They cannot display axis labels or multiple series in the same cell.
When deciding which to use, consider the purpose. Sparklines are perfect for inline, at-a-glance visuals within a table. Regular charts are better for presentations or when you need detailed annotations. You can also combine them: use sparklines for quick scanning and a full chart for a detailed view.
Advanced Options and Customization
Beyond charttype, SPARKLINE supports many options. Here are some useful ones:
color– sets the main color (e.g.,"color","#ff0000").linewidth– only for line charts, controls thickness (e.g.,"linewidth",3).highcolorandlowcolor– highlight the highest and lowest points (line and column).firstcolorandlastcolor– color the first and last data points.yminandymax– set the vertical axis minimum and maximum for consistent scaling across multiple sparklines.rtl– set totrueto render the sparkline from right to left (for RTL languages).
Example with multiple options: =SPARKLINE(B2:B20, {"charttype","column"; "color","#34a853"; "highcolor","#ff0000"; "ymin",0}) creates a column sparkline with a fixed minimum of zero.
Frequently Asked Questions
Can I make a sparkline show a trendline or average? No, sparklines do not support trendlines or average lines. They only display the raw data points. If you need a trendline, use a regular chart.
How do I create a sparkline that ignores empty cells? SPARKLINE automatically ignores empty cells in the range. If you have text or errors, use =SPARKLINE(FILTER(A2:A20, ISNUMBER(A2:A20))) to filter out non-numeric values.
Can I use SPARKLINE with data from another sheet? Yes, you can reference ranges from other sheets, like =SPARKLINE(Sheet2!A2:A20). The sparkline will update if the source data changes.
Why does my sparkline show a flat line even though my data varies? If your data has a very small range (e.g., values between 100 and 102), the line may appear flat. Set ymin and ymax to force a scale, or normalize your data.
Is SPARKLINE available in Excel? Excel has its own sparkline feature (Insert > Sparklines), but it is not a formula. The Google Sheets SPARKLINE formula is unique to Sheets. In Excel, you insert sparklines from the ribbon, and they are not dynamic in the same way.
Can I copy a sparkline to many cells? Yes, you can copy the formula down or across. Each cell will create its own sparkline based on the relative range. Use absolute references (e.g., $A$2:$A$20) if you want all sparklines to use the same data.
Related
- Google Sheets Google Translate Formula: How to Use It
- Google Translate for Google Sheets: Add-on or Formula?
- How to Change A, B, C in Google Sheets
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Pivot Table: Multiple Rows at the Same LevelYes. In Excel for Microsoft 365 on Windows, add each field to the PivotTable Rows area, then choose…
- Learn Pivot Tables: A Beginner’s GuideYes, you can learn pivot tables in a few hours by focusing on the core workflow: select your…
- Google Sheets Pivot Tables: Create, Customize, and RefreshYes, you can create a pivot table in Google Sheets using Insert > Pivot table. Select a range…
- Excel Stacked Bar Chart: Show Total Data LabelsTo show totals on an Excel stacked bar chart, add data labels to the series at the end…
- Excel Pivot Table Blank? Causes, Checks, and Fixes That WorkIf an Excel PivotTable is blank, first check its filters and source data, then refresh it and confirm…
- Excel Bar Over Bar Graph: How to Overlay Two Data SeriesTo put one data series over another in an Excel bar chart, select a bar, open Format Data…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.