From 80659fd224c57796e189878340832dbf1b80ed35 Mon Sep 17 00:00:00 2001 From: tonykau1 <25996568+tonykau1@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:13:07 -0800 Subject: [PATCH 1/2] add details to designing for metrics --- docs/pages/guides/designing-metrics.mdx | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/pages/guides/designing-metrics.mdx b/docs/pages/guides/designing-metrics.mdx index bd17eb6cccf91..1afe952f96c8f 100644 --- a/docs/pages/guides/designing-metrics.mdx +++ b/docs/pages/guides/designing-metrics.mdx @@ -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 @@ -115,4 +115,30 @@ 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 ``` \ No newline at end of file From 2b61c87762487026160de4dc6e1be7e185bf48b0 Mon Sep 17 00:00:00 2001 From: tonykau1 <25996568+tonykau1@users.noreply.github.com> Date: Wed, 20 Dec 2023 12:39:06 -0800 Subject: [PATCH 2/2] Update designing-metrics.mdx --- docs/pages/guides/designing-metrics.mdx | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/pages/guides/designing-metrics.mdx b/docs/pages/guides/designing-metrics.mdx index 1afe952f96c8f..f381ccdd1008a 100644 --- a/docs/pages/guides/designing-metrics.mdx +++ b/docs/pages/guides/designing-metrics.mdx @@ -141,4 +141,30 @@ views: - status - shipped_at -``` \ No newline at end of file +``` + +## 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 +```