Search code examples
sqllooker-studio

How to draw a time-series chart with two array columns(date, value) on google looker studio?


I have a data source that have 2 columns, "date" and "value".

It sorted by created time, for example,

date value
["2011-10-11", "2011-10-12", "2011-10-13"] [1,2,3]

Is there any way to create a chart for x-axis with date, y-axis with value?

Read looker studio docs, and try custom column but there's no processing method.


Solution

  • Using Custom SQL in Looker Studio, you can flatten the array and visualize it.

    select
      date, value 
    from unnest(["2011-10-11", "2011-10-12", "2011-10-13"]) date with offset idx1
    join unnest([1, 2, 3]) value with offset idx2 
    on idx1 = idx2;
    
    date value
    2011-10-11 1
    2011-10-12 2
    2011-10-13 3

    Looker Studio - Chart