From 570baf4ec5ed31884e4e6c5daa8fbfb2c5edd27a Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:09:32 +0100 Subject: [PATCH] Update metricflow-commands.md updating query examples to include missing primary entity prefix in group by command [refer to slack thread](https://dbt-labs.slack.com/archives/C04REFN03MX/p1727728803420059) --- website/docs/docs/build/metricflow-commands.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index 383b6680261..a3c5d0d6c4d 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -338,13 +338,13 @@ mf query --metrics order_total,users_active --group-by metric_time # In dbt Core -You can include multiple dimensions in a query. For example, you can group by the `is_food_order` dimension to confirm if orders were for food or not. +You can include multiple dimensions in a query. For example, you can group by the `is_food_order` dimension to confirm if orders were for food or not. Note that when you query a dimension, you need to specify the primary entity for that dimension. **Query** ```bash -dbt sl query --metrics order_total --group-by metric_time,is_food_order # In dbt Cloud +dbt sl query --metrics order_total --group-by primary_entity__is_food_order # In dbt Cloud -mf query --metrics order_total --group-by metric_time,is_food_order # In dbt Core +mf query --metrics order_total --group-by primary_entity__is_food_order # In dbt Core ``` **Result** @@ -368,13 +368,15 @@ mf query --metrics order_total --group-by metric_time,is_food_order # In dbt Cor You can add order and limit functions to filter and present the data in a readable format. The following query limits the data set to 10 records and orders them by `metric_time`, descending. Note that using the `-` prefix will sort the query in descending order. Without the `-` prefix sorts the query in ascending order. +Note that when you query a dimension, you need to specify the primary entity for that dimension. + **Query** ```bash # In dbt Cloud -dbt sl query --metrics order_total --group-by metric_time,is_food_order --limit 10 --order-by -metric_time +dbt sl query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time # In dbt Core -mf query --metrics order_total --group-by metric_time,is_food_order --limit 10 --order-by -metric_time +mf query --metrics order_total --group-byprimary_entity__is_food_order --limit 10 --order-by -metric_time ``` **Result** @@ -428,16 +430,16 @@ mf query --metrics order_total --group-by metric_time --where "{{ Dimension('ord To filter by time, there are dedicated start and end time options. Using these options to filter by time allows MetricFlow to further optimize query performance by pushing down the where filter when appropriate. - +Note that when you query a dimension, you need to specify the primary entity for that dimension. **Query** ```bash # In dbt Core -mf query --metrics order_total --group-by metric_time,is_food_order --limit 10 --order-by -metric_time --where "is_food_order = True" --start-time '2017-08-22' --end-time '2017-08-27' +mf query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time --where "is_food_order = True" --start-time '2017-08-22' --end-time '2017-08-27' ``` **Result**