Skip to content

Commit

Permalink
docs: Add details on Designing for metrics (#7493)
Browse files Browse the repository at this point in the history
* add details to designing for metrics

* Update designing-metrics.mdx
  • Loading branch information
tonykau1 authored Dec 21, 2023
1 parent 2740da4 commit 0f211d1
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions docs/pages/guides/designing-metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Views are exposed as tables in Cube SQL API, dimensions can be queried as is

## Metrics-first
In metrics-first approach, views are built around measures, or metrics, in your data model.
Views are built as denormalzied tables, containing one measure and all the relevant dimensions from different cubes.
Views are built as denormalzied tables, containing one measure and all the relevant dimensions from different cubes. These include all the dimensions you would group or filter by, and up to one time dimension.
Views are usually named after that single measure.

```yaml
Expand Down Expand Up @@ -115,4 +115,56 @@ SELECT
MEASURE(average_order_value)
FROM average_order_value
GROUP BY 1
```
```

NOTE: If a metric is interesting across more than one time dimension, create multiple views (metrics), one with each time dimension, and name the metric distinctly for each.
This approach improves compatibility with BI tooling and adds clarity for the consumer.

```yaml
views:
- name: order_count_by_order_date
cubes:
- join_path: orders
includes:
- order_count
- status
- created_at
- name: order_count_by_ship_date
cubes:
- join_path: orders
includes:
- order_count
- status
- shipped_at
```

## Integrations with BI Tools
Some metrics-based BI tools will specify requirements for the views or be able to accept additional metadata to enrich the experience.
Below is an example of using the `meta` property to do this.

```yaml
views:
- name: order_count_by_order_date
description: For finance team to track orders on accrual/earned basis.
meta:
type: metric
owner: alice@acme.com
cubes:
- join_path: orders
includes:
# MEASURE
- order_count
# TIME
- created_at
# DIMENSIONS
- status
- city
```

0 comments on commit 0f211d1

Please sign in to comment.