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

Update ratio-metrics.md to reflect use of metrics as inputs #3880

Merged
merged 2 commits into from
Aug 7, 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
30 changes: 16 additions & 14 deletions website/docs/docs/build/ratio-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Ratio
tags: [Metrics, Semantic Layer]
---

Ratio allows you to create a ratio between two measures. You simply specify a numerator and a denominator measure. Additionally, you can apply a dimensional filter to both the numerator and denominator using a constraint string when computing the metric.
Ratio allows you to create a ratio between two metrics. You simply specify a numerator and a denominator metric. Additionally, you can apply a dimensional filter to both the numerator and denominator using a constraint string when computing the metric.

The following displays the full spec for ratio metrics, along with an example:

Expand All @@ -17,26 +17,28 @@ metrics:
type: ratio # Required
label: The value that will be displayed in downstream tools #Required
type_params: # Required
numerator: the measure used for the numerator # Required
filter: filter for the numerator# Optional
alias: alias for the numerator # Optional
denominator: the measure used for the denominator # Required
filter: filter for the denominator # Optional
alias: alias for the denominator # Optional
numerator: the name of the metric used for the numerator, or a struct of properties as below # Required
name: name of metric used for the numerator # Required
filter: filter for the numerator# Optional
alias: alias for the numerator # Optional
denominator: the name of the metric used for the denominator, or a struct of properties as below # Required
name: name of metric used for the denominator # Required
filter: filter for the denominator # Optional
alias: alias for the denominator # Optional
```

## Ratio metrics example

```yaml
# Ratio Metric
metrics:
- name: food_order_total_pct
description: "The food order total as the % of the total order"
label: Food Order Total %
- name: food_order_pct
description: "The food order count as a ratio of the total order count"
label: Food Order Ratio
type: ratio
type_params:
numerator: food_order_total
denominator: order_total
numerator: food_orders
denominator: orders

```
## Ratio metrics using different semantic models
Expand Down Expand Up @@ -90,7 +92,7 @@ on

## Add filter

Users can define constraints on input measures for a metric by applying a filter directly to the measure, like so:
Users can define constraints on input metrics for a ratio metric by applying a filter directly to the input metric, like so:

```yaml
metrics:
Expand All @@ -108,4 +110,4 @@ metrics:
name: distinct_purchasers
```

Note the `filter` and `alias` parameters for the measure referenced in the numerator. Use the `filter` parameter to apply a filter to the measure it's attached to. The `alias` parameter is used to avoid naming conflicts in the rendered SQL queries when the same measure is used with different filters. If there are no naming conflicts, the `alias` parameter can be left out.
Note the `filter` and `alias` parameters for the metric referenced in the numerator. Use the `filter` parameter to apply a filter to the metric it's attached to. The `alias` parameter is used to avoid naming conflicts in the rendered SQL queries when the same metric is used with different filters. If there are no naming conflicts, the `alias` parameter can be left out.
Loading