From 0f211d1802308d780fd2f1e85e6ab89c5de224f0 Mon Sep 17 00:00:00 2001 From: tonykau1 <25996568+tonykau1@users.noreply.github.com> Date: Wed, 20 Dec 2023 19:41:10 -0800 Subject: [PATCH] docs: Add details on Designing for metrics (#7493) * add details to designing for metrics * Update designing-metrics.mdx --- docs/pages/guides/designing-metrics.mdx | 56 ++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/docs/pages/guides/designing-metrics.mdx b/docs/pages/guides/designing-metrics.mdx index bd17eb6cccf91..f381ccdd1008a 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,56 @@ SELECT MEASURE(average_order_value) FROM average_order_value GROUP BY 1 -``` \ No newline at end of file +``` + +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 +```