Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric date #6428

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions website/docs/docs/build/measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Parameters under the `non_additive_dimension` will specify dimensions that the m

```yaml
semantic_models:
- name: subscription_id
- name: subscriptions
description: A subscription table with one row per date for each active user and their subscription plans.
model: ref('your_schema.subscription_table')
defaults:
Expand All @@ -209,7 +209,7 @@ semantic_models:
entities:
- name: user_id
type: foreign
primary_entity: subscription_table
primary_entity: subscription
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and everything below looks good!


dimensions:
- name: subscription_date
Expand All @@ -224,21 +224,21 @@ semantic_models:
expr: user_id
agg: count_distinct
non_additive_dimension:
name: metric_time
name: subscription_date
window_choice: max
- name: mrr
description: Aggregate by summing all users' active subscription plans
expr: subscription_value
agg: sum
non_additive_dimension:
name: metric_time
name: subscription_date
window_choice: max
- name: user_mrr
description: Group by user_id to achieve each user's MRR
expr: subscription_value
agg: sum
non_additive_dimension:
name: metric_time
name: subscription_date
window_choice: max
window_groupings:
- user_id
Expand All @@ -255,15 +255,15 @@ We can query the semi-additive metrics using the following syntax:
For dbt Cloud:

```bash
dbt sl query --metrics mrr_by_end_of_month --group-by metric_time__month --order metric_time__month
dbt sl query --metrics mrr_by_end_of_month --group-by metric_time__week --order metric_time__week
dbt sl query --metrics mrr_by_end_of_month --group-by subscription__subscription_date__month --order subscription__subscription_date__month
dbt sl query --metrics mrr_by_end_of_month --group-by subscription__subscription_date__week --order subscription__subscription_date__week
```

For dbt Core:

```bash
mf query --metrics mrr_by_end_of_month --group-by metric_time__month --order metric_time__month
mf query --metrics mrr_by_end_of_month --group-by metric_time__week --order metric_time__week
mf query --metrics mrr_by_end_of_month --group-by subscription__subscription_date__month --order subscription__subscription_date__month
mf query --metrics mrr_by_end_of_month --group-by subscription__subscription_date__week --order subscription__subscription_date__week
```

import SetUpPages from '/snippets/_metrics-dependencies.md';
Expand Down
Loading