Looker Community

Time/Timestamp Measure

This help article describes how to use the date measure to calculate the min or max date for a group. Why isn’t there a similar measure for time? If I try to calculate the min or max timestamp for a group using this approach:

  measure: minimum_timestamp {
     type: date
     sql: MIN(${event_time}) ;;
  }

The measure returns the minimum timestamp for each group cast as a date. I’m not sure why I should accept this loss of precision for a pretty straightforward calculation.

Edit: as suggested in the last step of the help article, simply omitting the measure type will bypass this issue.

  measure: minimum_timestamp {
     sql: MIN(${event_raw}) ;;
     html: {{ rendered_value | date: "%Y-%m-%d %H:%M:%S" }} ;;
  }