Question

Difference between time dimension groups in the LookML

  • 13 October 2017
  • 1 reply
  • 598 views

Is it possible to designate a dimension group that is the difference between two others, or can I only specifically designate one timeframe. For example, I need to define a dimension that is something like the time between begin and end, where being_date and end_date are defined in the model as dimension groups.

I know I can designate, for example, the number of week in between the two dates as


DATEDIFF(WEEK, ${begin_date}, ${end_date})


Is there a way to abstract the date part in the calculation, so that I can pick the timeframe in the tile, as with the other dimension groups? In other words, is it possible to designate the difference between two time dimension groups?


1 reply

Userlevel 6
Badge

You can place arbitrary fields into a group using the group_label parameter, it doesn’t just have to be dates or times.


Here is the documentatation:


https://docs.looker.com/reference/field-params/group_label


For example:


dimension: length_in_minutes {
type: number
sql: TIMEDIFF(....) ;;
group_label: "Movie Length"
}

dimension: length_in_seconds {
type: number
sql: TIMEDIFF(....) ;;
group_label: "Movie Length"
}

dimension: length_in_hours {
type: number
sql: TIMEDIFF(....) ;;
group_label: "Movie Length"
}

Would show up in the explore like:


Reply