Skip to content

Instantly share code, notes, and snippets.

@strangeways
Last active May 24, 2018 13:36
Show Gist options
  • Select an option

  • Save strangeways/30d40a2399aaeb3fc72f to your computer and use it in GitHub Desktop.

Select an option

Save strangeways/30d40a2399aaeb3fc72f to your computer and use it in GitHub Desktop.
Google Sheets formula to generate a sparkline chart from the last 12 rows with values in a given column
=SPARKLINE(FILTER(A2:A, ROW(A2:A)>(MAX(FILTER(ROW(A2:A), ISNUMBER(A2:A)))-12), ROW(A2:A)<=MAX(FILTER(ROW(A2:A), ISNUMBER(A2:A)))))

Exploded view of formula:

=SPARKLINE(
  FILTER(
    A2:A,
    ROW(A2:A) > (MAX(FILTER( ROW(A2:A) , ISNUMBER(A2:A))) - 12),
    ROW(A2:A) <= MAX(FILTER( ROW(A2:A) , ISNUMBER(A2:A)))
  )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment