Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 1.11 KB

timeseries.md

File metadata and controls

35 lines (28 loc) · 1.11 KB

Time series line chart

Explore this snippet with some demo data here.

Description

Timeseries charts show how individual metric(s) change over time. They have lines along the y-axis and dates along the x-axis. You just need a simple GROUP BY to get all the elements you need for a timeseries chart:

SELECT 
   AGG_FN(<COLUMN>) as metric,
   <DATETIME_COLUMN> as datetime
FROM 
   <TABLE>
GROUP BY
   datetime

where:

  • AGG_FN is an aggregation function like SUM, AVG, COUNT, MAX, etc.
  • COLUMN is the column you want to aggregate to get your metric. Make sure this is a numeric column.
  • DATETIME_COLUMN is the group you want to show on the x-axis. Make sure this is a date, datetime, timestamp, or time column (not a number)

Usage

In this example with some spotify data, we'll look at the total daily streams over time:

select
  sum(streams) streams, 
  day 
from PUBLIC.SPOTIFY_DAILY_TRACKS
group by day

timeseries