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

docs: Add details on Designing for metrics #7493

Merged
merged 2 commits into from
Dec 21, 2023
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
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
```