You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/docs/build/metrics-overview.md
+11-3
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,11 @@ tags: [Metrics, Semantic Layer]
7
7
pagination_next: "docs/build/cumulative"
8
8
---
9
9
10
-
Once you've created your semantic models, it's time to start adding metrics. Metrics can be defined in the same YAML files as your semantic models, or split into separate YAML files into any other subdirectories (provided that these subdirectories are also within the same dbt project repo).
10
+
After building [semantic models](/docs/build/semantic-models), it's time to start adding metrics. This page explains the different supported metric types you can add to your dbt project
11
11
12
-
This article explains the different supported metric types you can add to your dbt project. The keys for metrics definitions are:
12
+
Metrics can be defined in the same YAML files as your semantic models, or defined in their dedicated separate YAML files located in any subdirectories within the same dbt project repository.
13
+
14
+
The keys for metrics definitions are:
13
15
14
16
<!-- for v1.8 and higher -->
15
17
@@ -107,7 +109,10 @@ It's possible to define a default time granularity for metrics if it's different
107
109
The granularity can be set using the `time_granularity` parameter on the metric, and defaults to `day`. If day is not available because the dimension is defined at a coarser granularity, it will default to the defined granularity for the dimension.
108
110
109
111
### Example
110
-
You have a semantic model called `orders` with a time dimension called `order_time`. You want the `orders` metric to roll up to `monthly` by default; however, you want the option to look at these metrics hourly. You can set the `time_granularity` parameter on the `order_time` dimension to `hour`, and then set the `time_granularity` parameter in the metric to `month`.
112
+
- You have a semantic model called `orders` with a time dimension called `order_time`.
113
+
- You want the `orders` metric to roll up to `monthly` by default; however, you want the option to look at these metrics hourly.
114
+
- You can set the `time_granularity` parameter on the `order_time` dimension to `hour`, and then set the `time_granularity` parameter in the metric to `month`.
115
+
111
116
```yaml
112
117
semantic_models:
113
118
...
@@ -130,6 +135,9 @@ metrics:
130
135
name: orders
131
136
time_granularity: month -- Optional, defaults to day
132
137
```
138
+
139
+
Remember that metrics can be defined in the same YAML files as your semantic models but must be defined as a separate top-level section and not nested within the `semantic_models` key. Or you can define metrics in their dedicated separate YAML files located in any subdirectories within the same dbt project repository.
0 commit comments