Skip to content

Commit

Permalink
add spec for metrics and measures
Browse files Browse the repository at this point in the history
  • Loading branch information
Jstein77 committed Jul 19, 2023
1 parent f05cf49 commit bc686db
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions website/docs/docs/build/measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ Measures are aggregations performed on columns in your model. They can be used a
| [`agg`](#aggregation) | dbt supports the following aggregations: `sum`, `max`, `min`, `count_distinct`, and `sum_boolean`. | Required |
| [`expr`](#expr) | You can either reference an existing column in the table or use a SQL expression to create or derive a new one. | Optional |
| [`non_additive_dimension`](#non-additive-dimensions) | Non-additive dimensions can be specified for measures that cannot be aggregated over certain dimensions, such as bank account balances, to avoid producing incorrect results. | Optional |
|[agg_params]| specific aggregation properties such as a percentile. | [Optional]|
|[agg_time_dimension]| The time field. Defaults to the default agg time dimension for the semantic model. | [Optional] |
|[non_additive_dimension]| configs used if needing non-additive dimensions | [Optional]|
|[label]| How the metric will be displayed in docs and downstream integrations. | [Required]|


## Measyres Spec
An example of the complete yaml measures spec is below. The actual configuration of your measures will depend on the aggregation you're using.

```
measures:
- name: The name of the measure # think transaction_total. If `expr` not present then this is the expected name of the column [Required]
description: same as always [Optional]
agg: the aggregation type. #think average, sum, max, min, etc.[Required]
expr: the field # think transaction_total or some other name you might want to alias [Optional]
agg_params: specific aggregation properties such as a percentile [Optional]
agg_time_dimension: The time field. Defaults to the default agg time dimension for the semantic model. [Optional]
non_additive_dimension: configs used if needing non-additive dimensions [Optional]
label: How the metric will be displayed in docs and downstream integrations. [Required]
`
### Name
Expand Down
14 changes: 14 additions & 0 deletions website/docs/docs/build/metrics-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ The keys for metrics definitions are:
* `constraint`: For any type of metric, you may optionally include a constraint string, which applies a dimensional filter when computing the metric. You may think of this as your WHERE clause.
* `meta`: Additional metadata you want to add to your metric.

An example of the complete metrics spec configuration is below:
```
metrics:
- name: metric name
description: same as always
type: the type of the metric
type_params:
- specific properties for the metric type
configs: here for `enabled`
label: The display name for your metric. This value will be shown in downstream tools.
filter: |
{{ dimension('name') }} > 0 and {{ dimension(' another name') }} is not null
```
This page explains the different supported metric types you can add to your dbt project.
<!--
- [Cumulative](#cumulative-metrics) — Cumulative metrics aggregate a measure over a given window.
Expand Down

0 comments on commit bc686db

Please sign in to comment.