Skip to main content
Measures describe how to aggregate data in Omni. Measure are either aggregates of dimensions such as max of profit, sum of revenue or transformations on top of other measures like sum of profit / count of users.

Semi-additive measures

Filtered measures are not currently supported as source measures for semi-additive measures.
Semi-additive measures are aggregations that can be added across some dimensions, but not all. Consider an end of day bank account balance. Summing this value across all days for a current balance would show an inaccurate number, as bank balances track an overall number rather than the incremental change from day to day. Leveraging semi-additive measures enables accurate tracking of the sum of the bank account across days while also allowing for slicing by other dimensions, such as account type. Semi-additive measures are possible through the omni_dimensionalize function. This function turns a measure, such as max(${date}) into a dimension, which can then be used for filtering within a given period. The newly converted dimensions are able to be used in subsequent logic to filter other measures and fields within the given query’s grouping. An example below demonstrates first creating a last known date, which is the maximum created at date with the query’s grouping. Then, the last_date is used to check if the given date is equivalent to the max date within the grouping:
dimensions:
  last_date:
    hidden: true
    sql: omni_dimensionalize(max(${created_at}))
  is_last_date:
    hidden: true
    sql: ${created_at[date]}=${last_date[date]}
    
measures:
  semi_additive_sum:
    sql: ${sale_price}
    aggregate_type: sum
    filters:
      is_last_date:
        is: true
From this, you can build a filtered measure that includes the boolean field as a filter.