Skip to content

Commit

Permalink
add add'l example to explain add'l properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Oct 2, 2024
1 parent 0b95005 commit 2af5f7d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions website/docs/docs/build/ratio-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ For advanced data modeling, you can use `fill_nulls_with` and `join_to_timespine

## Ratio metrics example

These examples demonstrate how to create ratio metrics in your model. They cover basic and advanced use cases, including applying filters to the numerator and denominator metrics.

#### Example 1
This example is a basic ratio metric that calculates the ratio of food orders to total orders:

```yaml
metrics:
- name: food_order_pct
Expand All @@ -56,6 +61,27 @@ metrics:
denominator: orders
```

#### Example 2
This eample is a ratio metric that calculates the ratio of food orders to total orders, with a filter and alias applied to the numerator:

```yaml
metrics:
- name: food_order_pct
description: "The food order count as a ratio of the total order count, filtered by location"
label: Food order ratio by location
type: ratio
type_params:
numerator:
name: food_orders
filter: location = 'New York'
alias: ny_food_orders
denominator:
name: orders
filter: location = 'New York'
alias: ny_orders
```


## Ratio metrics using different semantic models

The system will simplify and turn the numerator and denominator into a ratio metric from different semantic models by computing their values in sub-queries. It will then join the result set based on common dimensions to calculate the final ratio. Here's an example of the SQL generated for such a ratio metric.
Expand Down

0 comments on commit 2af5f7d

Please sign in to comment.