Skip to content

Commit

Permalink
Merge branch 'current' into Tonayya-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Aug 9, 2023
2 parents 4d2cb37 + 72b89de commit e623d88
Show file tree
Hide file tree
Showing 43 changed files with 363 additions and 229 deletions.
1 change: 0 additions & 1 deletion website/blog/2021-09-15-september-21-product-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: "dbt v1.0 is coming up! Don't forget to update your projects to the
slug: dbt-product-update-2021-september
authors: [lauren_craigie]

tags: [dbt updates]
hide_table_of_contents: false

date: 2021-09-15
Expand Down
1 change: 0 additions & 1 deletion website/blog/2021-10-15-october-21-product-update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: "Stay up-to-date with the latest features in dbt. Read about our Oc
slug: dbt-product-update-2021-october
authors: [lauren_craigie]

tags: [dbt updates]
hide_table_of_contents: false

date: 2021-10-15
Expand Down
1 change: 0 additions & 1 deletion website/blog/2021-11-15-november-21-product-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: "Stay up-to-date with the latest features in dbt. Read about our No
slug: dbt-product-update-2021-november
authors: [lauren_craigie]

tags: [dbt updates]
hide_table_of_contents: false

date: 2021-11-15
Expand Down
1 change: 0 additions & 1 deletion website/blog/2022-08-31-august-product-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: "Coalesce is less than 2 months away!"
slug: dbt-product-update-2022-august
authors: [lauren_craigie]

tags: [dbt updates]
hide_table_of_contents: false

date: 2022-08-31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ description: "Going polyglot is a major next step in the journey of dbt Core. It
slug: polyglot-dbt-python-dataframes-sql

authors: [doug_beatty]

tags: [dbt product updates]
tags: [dbt tutorials]
hide_table_of_contents: false

date: 2022-10-18
Expand Down
1 change: 0 additions & 1 deletion website/blog/2023-04-26-deprecating-dbt-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ slug: deprecating-dbt-metrics

authors: [callum_mccann]

tags: [dbt product updates]
hide_table_of_contents: false

date: 2023-04-26
Expand Down
1 change: 0 additions & 1 deletion website/blog/2023-05-01-evolving-data-engineer-craft.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ slug: evolving-data-engineer-craft

authors: [sung_chung, kira_furuichi]

tags: [dbt product updates]
hide_table_of_contents: false

date: 2023-05-01
Expand Down
4 changes: 0 additions & 4 deletions website/blog/categories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
display_title: dbt tutorials
description: Best practices in the usage of our favorite data transformation tool.
is_featured: true
- name: dbt updates
display_title: dbt product updates
description: An archive of monthly product updates from the dbt Labs team.
is_featured: true
- name: SQL magic
display_title: SQL magic
description: Stories of dbt developers making SQL sing across warehouses.
Expand Down
92 changes: 51 additions & 41 deletions website/docs/docs/build/cumulative-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,45 @@ sidebar_label: Cumulative
tags: [Metrics, Semantic Layer]
---

Cumulative metrics aggregate a measure over a given accumulation window. If no window is specified, the window is considered infinite and accumulates values over all time.
Cumulative metrics aggregate a measure over a given accumulation window. If no window is specified, the window is considered infinite and accumulates values over all time. You will need to create the [time spine model](/docs/build/metricflow-time-spine) before you add cumulative metrics.

This metric is common for calculating things like weekly active users, or month to date revenue. The following displays the full metrics spec, along with an example:
This metric is common for calculating things like weekly active users, or month to date revenue. The parameters, description, and type for cumulative metrics are:

| Parameter | Description | Type |
| --------- | ----------- | ---- |
| `name` | The name of the metric. | Required |
| `description` | The description of the metric. | Optional |
| `type` | The type of the metric (cumulative, derived, ration, or simple). | Required |
| `label` | The value that will be displayed in downstream tools. | Required |
| `type_params` | The type parameters of the metric. | Required |
| `measure` | The measure you are referencing. | Required |
| `window` | The accumulation window, such as 1 month, 7 days, 1 year. This can't be used with `window`. | Optional |
| `grain_to_date` | Sets the accumulation grain, such as month will accumulate data for one month. Then restart at the beginning of the next. This can't be used with window. | Optional |

The following displays the complete specification for cumulative metrics, along with an example:

```yaml
metrics:
- name: the metric name # Required
description: the metric description # Optional
- name: The metric name # Required
description: The metric description # Optional
type: simple # Required
label: The value that will be displayed in downstream tools # Required
type_params: # Required
measure: the measure you are referencing # Required
window: the accumulation window i.e 1 month, 7 days, 1 year. # Optional. Cannot be used with grain_to_date
grain_to_date: sets the accumulation grain, such as month will accumulate data for one month, then restart at the beginning of the next.
# Optional. Can not be used with window.

measure: The measure you are referencing # Required
window: The accumulation window, such as 1 month, 7 days, 1 year. # Optional. Can not be used with window.
grain_to_date: Sets the accumulation grain, such as month will accumulate data for one month, then restart at the beginning of the next. # Optional. Cannot be used with grain_to_date

```

:::info MetricFlow time spine required
## Cumulative metrics example


:::tip MetricFlow time spine required

You will need to create the [time spine model](/docs/build/metricflow-time-spine) before you add cumulative metrics.

:::

## Cumulative metrics example

Cumulative metrics measure data over a given window and consider the window infinite when no window parameter is passed, accumulating the data over all time.

```yaml
Expand Down Expand Up @@ -75,9 +86,10 @@ Suppose the underlying measure `customers` which is configured to count the uniq

```yaml
measures:
- name: customers
expr: customer_id
agg: count_distinct
- name: customers
expr: customer_id
agg: count_distinct
```

We can write a cumulative metric `weekly_customers` as such:
Expand Down Expand Up @@ -118,31 +130,29 @@ Suppose you (a subscription-based company for the sake of this example) have an
Using cumulative metrics without specifying a window, you can calculate running totals for metrics like the count of active subscriptions and revenue at any point in time. The following configuration YAML displays creating such cumulative metrics to obtain current revenue or total number of active subscriptions as a cumulative sum:

```yaml
measures:
- name: revenue
description: Total revenue
agg: sum
expr: revenue
- name: subscription_count
description: Count of active subscriptions
agg: sum
measures:
- name: revenue
description: Total revenue
agg: sum
expr: revenue
- name: subscription_count
description: Count of active subscriptions
agg: sum
expr: event_type
metrics:
- name: current_revenue
description: Current revenue
label: Current Revenue
type: cumulative
type_params:
measure: revenue
- name: active_subscriptions
description: Count of active subscriptions
label: Active Subscriptions
type: cumulative
type_params:
measure: subscription_count
metrics:
- name: current_revenue
description: Current revenue
label: Current Revenue
type: cumulative
type_params:
measures:
- revenue
- name: active_subscriptions
description: Count of active subscriptions
label: Active Subscriptions
type: cumulative
type_params:
measures:
- subscription_count
```

</TabItem>
Expand All @@ -165,14 +175,14 @@ We can compare the difference between a 1-month window and a monthly grain to da

```yaml
metrics:
- name: cumulative_order_total_l1m #For this metric, we use a window of 1 month
label: Cumulative Order total (L1M)
- name: cumulative_order_total_l1m #For this metric, we use a window of 1 month
label: Cumulative Order total (L1M)
description: Trailing 1 month cumulative order amount
type: cumulative
type_params:
measure: order_total
window: 1 month
- name: cumulative_order_total_mtd #For this metric, we use a monthly grain to date
- name: cumulative_order_total_mtd #For this metric, we use a monthly grain to date
label: Cumulative Order total (MTD)
description: The month to date value of all orders
type: cumulative
Expand Down
19 changes: 17 additions & 2 deletions website/docs/docs/build/derived-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ tags: [Metrics, Semantic Layer]

In MetricFlow, derived metrics are metrics created by defining an expression using other metrics. They allow performing calculations on top of existing metrics. This proves useful for combining metrics and applying arithmetic functions to aggregated columns, such as, you can define a profit metric.

The following example presents the complete specification for derived metrics, along with an example.
The parameters, description, and type for derived metrics are:

| Parameter | Description | Type |
| --------- | ----------- | ---- |
| `name` | The name of the metric. | Required |
| `description` | The description of the metric. | Optional |
| `type` | The type of the metric (cumulative, derived, ration, or simple). | Required |
| `label` | The value that will be displayed in downstream tools. | Required |
| `type_params` | The type parameters of the metric. | Required |
| `expr` | The derived expression. | Required |
| `metrics` | The list of metrics used in the derived metrics. | Required |
| `alias` | Optional alias for the metric that you can use in the expr. | Optional |
| `filter` | Optional filter to apply to the metric. | Optional |
| `offset_window` | Set the period for the offset window, such as 1 month. This will return the value of the metric one month from the metric time. | Required |

The following displays the complete specification for derived metrics, along with an example.

```yaml
metrics:
Expand Down Expand Up @@ -70,7 +85,7 @@ metrics:
## Derived metric offset
You may want to use an offset value of a metric in the definition of a derived metric. For example, you can model the retention rate by using a derived metric with an offset, which involves calculating (active customers at the end of the month/active customers at the beginning of the month) - 1.
You may want to use an offset value of a metric in the definition of a derived metric. For example, you can model the retention rate by using a derived metric with an offset, which involves calculating (active customers at the end of the month/active customers at the beginning of the month).
```yaml
metrics:
Expand Down
Loading

0 comments on commit e623d88

Please sign in to comment.