Number.Tanh

Number

Returns the hyperbolic tangent of a number.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Number.Tanh(number as nullable number) as nullable number

Parameters

NameTypeRequiredDescription
numbernumberYesThe number whose hyperbolic tangent is computed.

Return Value

numberThe 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 1: Hyperbolic tangent of 0 is 0

Result
Result
10

Example 2: Large inputs approach ±1 asymptotically

Result
Result
11.00

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}))
Applied Steps

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
300
410.76
531.00

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks