Proposal: metric additivity (additive / semi-additive / non-additive) in the core spec #465
harrydevforlife
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
In the current core spec (
core-spec/spec.md), a metric is onlyname,expression,description,datatype,ai_contextandcustom_extensions. There is no way to declare how a metric may be aggregated across dimensions.For fully additive metrics (
SUM(revenue)) and clearly non-additive ones (COUNT(DISTINCT user_id), ratios) a consumer can often infer behaviour from the expression. But semi-additive metrics cannot be inferred:SUM(balance), inventory levels, or daily-active snapshots are summable across users/regions but must not be summed across time (you want last / first / average over the period instead). Today the only options are vendor-specificcustom_extensionsorai_contexthints, neither of which is portable or enforceable by query engines.Proposal
Add optional, portable additivity metadata to the Metric object, e.g.:
Prior art: dbt/MetricFlow
non_additive_dimension(withwindow_choiceandwindow_groupings), Cube, SSAS semi-additive measures (LastNonEmpty, etc.).Open questions
additivitybe explicit, or derived fromnon_additive_dimensionsbeing present?is_timefields and time-grain handling?Happy to help draft a PR if there is interest.
All reactions