Skip to main content
Duration dimensions automatically generate multiple interval variations (such as days, weeks, months, years) to provide flexible time difference analysis. Duration dimensions behave similarly to timeframe dimensions, automatically creating parameterized versions of the field for different time intervals.
You can also create duration fields directly from the workbook UI by right-clicking on a timestamp field and selecting Duration. Refer to Creating duration fields from the workbook for more information.

Syntax

<dimension_name>:
  duration:
    intervals: [<interval_1>, <interval_2>, ...]
    sql_start: <start_timestamp_field>
    sql_end: <end_timestamp_field>

Properties

dimension_name
object
The name of the dimension. Dimension names must:
  • Be unique within the view
  • Start with a letter
  • Contain only alphanumeric characters and underscores

Referencing duration dimensions

Duration dimensions can be referenced in the model using parameterized syntax, similar to timeframes:
  • ${order_fulfillment_time[days]}
  • ${order_fulfillment_time[hours]}
  • ${order_fulfillment_time[weeks]}
Note: Unparameterized references will always return null. For example, a reference like ${order_fulfillment_time} will be null.

Examples

Order fulfillment duration
order_fulfillment_time:
  duration:
    sql_start: ${orders.created_at}
    sql_end: ${orders.shipped_at}
    intervals: [hours, days, weeks]
User account age
account_age:
  duration:
    sql_start: ${users.created_at}
    sql_end: ${users.last_login_at}
    intervals: [days, months, years]
Project duration with all intervals
project_length:
  duration:
    sql_start: ${projects.start_date}
    sql_end: ${projects.end_date}
    intervals: [days, weeks, months, quarters, years]
  • timeframes - For time segmentation of timestamp fields
  • sql - For custom field calculations