# Math & numeric
URL: https://docs.valsight.ai/math-numeric/
Description: Use this category when you need numeric transformations and helpers in formulas.
Use this category when you need **numeric transformations and helpers** in formulas.

These functions change values row-wise and support tasks such as rounding, caps and floors, powers, roots, logarithms, and element-wise adjustments.

## Start here if you want to:

* Use **numeric helpers** such as rounding, caps/floors, sign, or modulo
* Apply **an element-wise constant change**
* Use **powers, roots, or logarithms**
* Use controlled **multiplication or division** with optional mismatch validation

## Not here if you want to:

* Reshape output granularity → see [Dimensionality & hierarchies](/dimensionality-hierarchies/)
* Use conditions, comparisons, or branching logic → see [Logical functions](/logical-functions/)
* Use time comparisons or projections → see [Compare periods](/compare-periods/) or [Rollforward & time series](/rollforward-time-series/)

## Mental model

* Most functions in this category work row-wise and usually keep the input shape
* Constants are 0-dimensional; if `+ 1` causes unexpected aggregation effects, use `ADDEACH` for an explicit element-wise adjustment

## Common patterns

| Name                                 | What it does                                                                      | Formula                                                                          |
| ------------------------------------ | --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| Add a constant to every cell         | Use when you want an element-wise change without aggregation side effects.        | `ADDEACH('Sales', 1)`                                                            |
| Compute a display-style ratio        | Keeps only the shared dimensionality of both inputs. `RATIO` must be an end node. | `RATIO('Gross Profit', 'Revenue')`                                               |
| Cap / floor values                   | Use when you need simple numeric thresholds without `IF`.                         | `MAX('Margin', 0)` or `MIN('Node1', 'Node2')`                                    |
| Round for reporting                  | Use when you need stable rounding for display or downstream steps.                | `ROUND('Revenue')`                                                               |
| Safe divide or multiply              | Use when you want clearer mismatch feedback instead of raw `/` or `*`.            | `DIVIDE('Node1', 'Node2', "FailOnMissingFirst")`                                 |
| Transform with logs, power, or roots | Use when your method requires non-linear scaling.                                 | `LN('Node')`, `LOG('Node1', 'Node2')`, `POWER('Node1', 'Node2')`, `SQRT('Node')` |

## Functions in this category

| Function               | Description                                                                                                                                         |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ABS](/abs/)           | Returns the absolute value of each value in the node.                                                                                               |
| [ADDEACH](/addeach/)   | Adds the specified amount to each row in the node without aggregation.                                                                              |
| [DIVIDE](/divide/)     | Divides the first input by the second with optional validation that provides detailed errors on mismatches.                                         |
| [MULTIPLY](/multiply/) | Multiplies inputs with optional validation that provides detailed errors on mismatches.                                                             |
| [EXP](/exp/)           | Calculates *e* (≈2.718) raised to the power of the input values.                                                                                    |
| [FACT](/fact/)         | Returns the factorial of each input value.                                                                                                          |
| [LN](/ln/)             | Returns the natural logarithm of the input.                                                                                                         |
| [LOG](/log/)           | Returns the logarithm of a value with respect to a specified base.                                                                                  |
| [MAX](/max/)           | Returns the row-wise maximum of two nodes.                                                                                                          |
| [MIN](/min/)           | Returns the row-wise minimum of two nodes.                                                                                                          |
| [MOD](/mod/)           | Returns the remainder after dividing the first input by the second.                                                                                 |
| [POWER](/power/)       | Raises values from the first node to exponents from the second input.                                                                               |
| [RATIO](/ratio/)       | Divides the first node by the second while retaining only joint dimensions. Must be an end node; the result cannot be used in further calculations. |
| [ROUND](/round/)       | Rounds each value to a specified number of decimal digits.                                                                                          |
| [SIGNUM](/signum/)     | Returns the sign of each number: 1 for positive, −1 for negative, 0 for zero.                                                                       |
| [SQRT](/sqrt/)         | Returns the square root of each value in the node.                                                                                                  |

## Choosing between similar functions

**ADDEACH vs** `+` with a constant

* Use `ADDEACH` when you want an explicit element-wise adjustment
* Use `+` with a constant only if you intentionally want standard arithmetic behavior with a 0-dimensional value

**DIVIDE/DIVISION (/) vs RATIO**

* Use `DIVISION (/)` for standard division
* Use `DIVIDE` when you want standard division with optional mismatch validation
* Use `RATIO` when you want a ratio that keeps only joint dimensions for display purposes; `RATIO` must be an end node

**MIN/MAX vs IF**

* Use `MIN`**/**`MAX` for simple caps and floors
* Use `IF` when the rule depends on broader conditional logic

**LN vs LOG vs EXP**

* Use `LN` for natural logarithm
* Use `LOG` when you need a specific base
* Use `EXP` for exponentiation with base `e`

## Pitfalls & troubleshooting

* **Unexpected aggregation after adding a constant:** replace `+ 1` style adjustments with `ADDEACH`
* RATIO **cannot be reused downstream**: if the result must feed other nodes, use `/` or `DIVIDE` and set aggregation appropriately
* **Division looks wrong:** check denominators for zero or missing values and validate both inputs at the same intersections
* **LN/LOG/SQRT return missing results:** confirm the input domain (negative values or zeros where not supported)
* **Rounding drift**: apply `ROUND` late, not in intermediate calculations

## Related

* [Operators](/operators/): arithmetic used around numeric functions
* [Logical functions](/logical-functions/): conditions and branching with `IF`
* [Troubleshooting guide](/troubleshooting-guide/): missing values, alignment issues, and unexpected shape changes
* [Function catalog](/function-catalog/): full signatures, parameters, and examples
