Passing user input date to where clause filter to the resultset

Dear all,

I would like to get your thoughts on the below scenario.

I have a table with a reporting date as a column and associated other dimensions and measures fields.

I would like to have the user input  a start date  filter (only from the list of dates from the reporting date column )   and also the end date filter ( only from the list of dates from the same reporting date column). 

So I can   aggregate measure based on start date and end date for variance analysis calculation and derived more calculation based on it (without creating a derived table, can this achieved by same table).

  In tableau i used to pass parameter directly to where SQL and reference the same to aggregate current selected date and previous selected date to derive variance metrics. ( I would like achieve the same in LOOKER not data studio)

Thanks

 

 

 

 

0 2 343
2 REPLIES 2

You can use Liquid parameters within SQL command to achieve this.
Firstly, you will have to create a date filter in lookml and refer its value in sql command using liquid parameter.
Here's the link to it 
Liquid variable reference  |  Looker  |  Google Cloud

Thanks for the reply.

I tried below from the link that you shared. but didn't work for me. maybe I'm missing something.

view: table_part_by_yyyy_mm_dd {
  sql_table_name: hive.taxi.table_part_by_yyyy_mm_dd ;;
  filter: date_filter {
    type: date
    sql: ( coalesce( ${dt} >= date_format({% date_start date_filter %}, '%Y-%m-%d'), TRUE) )
    AND ( coalesce( ${dt} <= date_format({% date_end date_filter %}, '%Y-%m-%'), TRUE) );;
  }
  dimension: dt {
    type: string
    sql: ${TABLE}.dt ;;
  }
}
Top Labels in this Space