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 3 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
20 changes: 10 additions & 10 deletions website/docs/docs/build/measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@ Parameters under the `non_additive_dimension` will specify dimensions that the m

```yaml
semantic_models:
- name: subscription_id
- name: subscription
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this subscriptions (plural)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely

matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
description: A subscription table with one row per date for each active user and their subscription plans.
model: ref('your_schema.subscription_table')
model: ref('your_schema.subscription')
Copy link
Contributor

Choose a reason for hiding this comment

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

You can leave this how it was! The table name doesn't need to match the semantic model name.

matthewshaver marked this conversation as resolved.
Show resolved Hide resolved
defaults:
agg_time_dimension: subscription_date

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