Kater SQL Functions Calculation context
RATIO
Divides one value by another on each row, such as units by orders.
Family: Calculation context
Syntax
RATIO(value, baseline)Arguments
| Argument | Description |
|---|---|
value | The number to divide: a measure or an expression. |
baseline | The number to divide by: a measure or an expression. |
Returns
The value divided by the baseline. It is null when the baseline is zero or a value is missing.
Usage notes
- A measure in either argument is worked out at the row’s grouping, so the ratio is the ratio of the row’s totals.
Example
This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.
SELECT orders.channel AS "Channel", EVAL(orders.sum__quantity) AS "Units", EVAL(orders.count_distinct__order_id) AS "Orders", RATIO(orders.sum__quantity, orders.count_distinct__order_id) AS "Units per Order"FROM kater_dataset.orders AS ordersGROUP BY orders.channelORDER BY 1| Channel | Units | Orders | Units per Order |
|---|---|---|---|
| 2,383 | 778 | 3.06 | |
| paid | 2,292 | 762 | 3.01 |
| store | 2,330 | 754 | 3.09 |
| web | 2,149 | 706 | 3.04 |