Presenting a date filter range in a dimension

low_priority
done
reply
(Ben Silverstein) #1

Hey there, smart people.

I have a date filter that users apply for a cohort analysis. My goal is to show a single value tile depicting the range contained within that date filter (i.e. presenting “Friday, June 21 2019 - Thursday, July 17 2019” without quotes). I’m certain there are several ways to do this (as with most things in Looker), but if anyone’s been through this and has some guidance to offer, it’d be greatly appreciated. Thanks in advance :slight_smile:

0 Likes

(Jackson Alvarez) #2
  filter: my_filter {
    type: date
  }
  
  dimension: show_my_filter {
    type: string
    sql: CONCAT( CAST({% date_start my_filter %} AS string)," - ", CAST({% date_end my_filter %} AS string)) ;;
  }

you can use date_start and date_end which will return the filter values. You can then do concat or substr and such to build the proper string to display.

You can do stuff with format_timestamp to make it like in your example, too.
https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#supported-format-elements-for-timestamp

2 Likes

(Ben Silverstein) #3

Thanks for your help, Jackson! I forgot to cast them as strings - d’oh!

0 Likes