Formula Patterns

Chart price data with SPARKLINE

Nest SF_SPARK inside the Google Sheets SPARKLINE function to draw a compact price chart in one cell.

Sparklines are supported in Google Sheets only. Excel support is not yet available.

Basic price sparkline

=SPARKLINE(SF_SPARK(A3, 1825, "price"), {"color", "red"})

This returns a small line chart of the closing price for the last approximately 5 years (1825 market days) in the cell where the formula is entered.

How it works

  1. SF_SPARK returns a one-dimensional array of price values.

  2. Without SPARKLINE, the array would spill down multiple cells.

  3. Wrapping it with SPARKLINE consumes the array in a single cell and renders it as a chart.

Customizing the chart

Use Google Sheets SPARKLINE options to change the style.

=SPARKLINE(SF_SPARK(A3, 365, "price"), {"charttype", "column"; "color", "green"})

Available chart types include line, column, and bar. The second argument to SF_SPARK is the number of market days, not calendar days.

What is next

For more on single-cell outputs, read Get a single value from a multi-row function. For troubleshooting array errors, see Fix common spreadsheet errors.

Was this helpful?