# RATIO
URL: https://docs.valsight.ai/ratio/
Description: Divides one node by another while retaining only their shared dimensions, recalculating the ratio dynamically at each aggregation level. Intended for display-only ratios in dashboards and reports.
**Category:** [Math & numeric](/math-numeric/)

> **End-Node Restriction.**
> The **RATIO** function should be an end node. It **should not be referenced by other nodes** or used in further calculations. Doing so will cause the dynamic recalculation behavior to be lost, producing potentially incorrect results.
>
> RATIO is designed for visualization and reporting purposes only. If you need a calculable ratio, see "Alternative: Division with Weighted-Average Aggregation" below.

## Overview

The **RATIO** function **divides one node by another while retaining only the dimensions shared by both nodes.**

Unlike a standard division (`'Node1' / 'Node2'`), RATIO dynamically recalculates the ratio at every aggregation level displayed in the workspace. For example, when switching from a monthly to a quarterly view, the ratio is recomputed from the quarterly totals rather than averaging the monthly ratios.

Use this function when you need a ratio that stays correct across different aggregation levels in dashboards and reports.

## Syntax

`RATIO('Node1', 'Node2')`

**Example usage:** `RATIO('Revenue', 'Quantity')`

## Parameters

| Parameter | Description                                 | Type           | Required |
| --------- | ------------------------------------------- | -------------- | -------- |
| **Node1** | Dividend. The node whose values are divided | Node reference | Yes      |
| **Node2** | Divisor. The node whose values divide Node1 | Node reference | Yes      |

## Output shape

| Aspect         | Behavior                                                                   |
| -------------- | -------------------------------------------------------------------------- |
| Dimensionality | Only dimensions shared by both input nodes are kept                        |
| Values         | Values are recalculated dynamically per aggregation level in the workspace |
| Row count      | Depends on shared dimensional combinations                                 |

## Watch out

* RATIO is not a standard calculation node.
* The function should not be referenced by other nodes.
* The result is recomputed dynamically when the aggregation level changes.
* Only shared dimensions between both nodes appear in the result.

## Examples

### Basic ratio

**Input node:** `'A'`

| Year | Value |
| ---- | ----- |
| 2025 | 15    |
| 2026 | 28    |
| 2027 | 126   |

**Input node:** `'B'`

| Year | Value |
| ---- | ----- |
| 2025 | 2     |
| 2026 | 2     |
| 2027 | 3     |

**Formula:** `RATIO('A', 'B')`

| Year | RATIO Result |
| ---- | ------------ |
| 2025 | 7.5          |
| 2026 | 14           |
| 2027 | 42           |

At the individual year level, RATIO produces the same results as division. The difference appears when you aggregate:

| Level | Plain division (incorrect)                     | RATIO (correct)                                                           |
| ----- | ---------------------------------------------- | ------------------------------------------------------------------------- |
| Total | Average of ratios:  (7.5 + 14 + 42) / 3 = 21.2 | Recalculated from totals:  (15 + 28 + 126) / (2 + 2 + 3) = 169 / 7 ≈ 24.1 |

RATIO recomputes the division from the aggregated totals, giving the mathematically correct result.

### Inputs with different dimensions

When Node1 and Node2 have different dimensions, only the shared dimensions appear in the result.

**Input node:** `'Revenue'`

| Year | Region | Value |
| ---- | ------ | ----- |
| 2025 | EMEA   | 500   |
| 2025 | APAC   | 300   |
| 2026 | EMEA   | 600   |
| 2026 | APAC   | 400   |

**Input node:** `'Headcount'`

| Year | Value |
| ---- | ----- |
| 2025 | 50    |
| 2026 | 55    |

**Formula:** `RATIO('Revenue', 'Headcount')`

| Year | Calculation      | Result |
| ---- | ---------------- | ------ |
| 2025 | (500 + 300) / 50 | 16     |
| 2026 | (600 + 400) / 55 | ≈ 18.2 |

Region is not shared by both nodes, so it is not present in the output. Revenue is aggregated across regions before dividing by headcount.

## Alternative

**Division with Weighted-Average Aggregation**

If you need a ratio result that **can be used in further calculations**, do not use RATIO.

**Instead**:

1. Create a regular division node: `'Node1' / 'Node2'`
2. Set the node's **aggregation type to "weighted average"** (with the divisor as the weight node).

This produces a similar weighted ratio across aggregation levels, but the result is a standard node that can be referenced by other calculations. Note that the aggregation behavior may not be identical to RATIO in all cases.

## Related

| Function                   | When to use instead                                                                 |
| -------------------------- | ----------------------------------------------------------------------------------- |
| [DIVISION (/)](/division/) | When you want standard division that keeps the union of dimensions from both nodes. |
| [DIVIDE](/divide/)         | When you want division with validation for missing rows.                            |
