Number.Tanh
NumberReturns the hyperbolic tangent of a number.
Syntax
Number.Tanh(number as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
number | number | Yes | The number whose hyperbolic tangent is computed. |
Return Value
number — The hyperbolic tangent of the number, in the range (-1, 1).
Remarks
Number.Tanh returns the hyperbolic tangent, defined mathematically as:
tanh(x) = sinh(x) / cosh(x) = (e^x − e^(−x)) / (e^x + e^(−x))
The result is always in the open interval (-1, 1). As x approaches +∞, tanh(x) approaches 1 asymptotically; as x approaches -∞, it approaches -1. At x = 0 the result is exactly 0. The function is odd: tanh(-x) = -tanh(x).
A practical feature of Number.Tanh is that it provides a smooth, bounded normalization of any real number to the range (-1, 1) without a hard clamp. This makes it useful in Power Query when you need to squash outliers while preserving the ordering and sign of values. Values close to zero change nearly linearly (slope ≈ 1 at x=0), while extreme values get compressed toward ±1. For normalizing to (0, 1) instead, the logistic function 1 / (1 + Number.Exp(-x)) is the standard alternative.
Unlike circular trigonometric functions, hyperbolic functions do not take angles in radians or degrees — they accept any real number.
Examples
Example 3: Normalize revenue z-scores to (-1, 1) using tanh
let
Scores = {-3.0, -1.0, 0.0, 1.0, 3.0},
Normalized = List.Transform(Scores, Number.Tanh)
in
#table({"ZScore", "Tanh"}, List.Zip({Scores, Normalized}))The final output — a two-column table pairing each original z-score with its tanh-normalized equivalent.
ZScore | Tanh | |
|---|---|---|
| 1 | -3 | -1.00 |
| 2 | -1 | -0.76 |
| 3 | 0 | 0 |
| 4 | 1 | 0.76 |
| 5 | 3 | 1.00 |