Number.Ln
NumberReturns the natural logarithm (base e) of a number.
Syntax
Number.Ln(number as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
number | number | Yes | The number whose natural logarithm is computed. Must be positive for a real result. |
Return Value
number — The natural logarithm of the number (log base e).
Remarks
Number.Ln computes the natural logarithm — the logarithm to base e (Euler's number, approximately 2.71828). It is the inverse of Number.Exp: Number.Ln(Number.Exp(x)) = x for any real x, and Number.Exp(Number.Ln(x)) = x for any positive x.
Inputs must be strictly positive for a real result. Passing 0 returns negative infinity; passing a negative number returns NaN rather than raising an error. Always validate or filter your data for non-positive values before applying Number.Ln in a table column.
Number.Ln is more efficient and numerically precise than Number.Log(x) with no base argument — both compute the natural log, but Number.Ln is the dedicated function. For base-10 log use Number.Log10; for an arbitrary base use Number.Log(x, base).
Common uses in data transformation: log-normalizing right-skewed distributions (revenue, population), computing entropy or information gain, and implementing continuous compounding formulas. Note that Number.Ln of a ratio gives the difference of natural logs: Number.Ln(a/b) = Number.Ln(a) - Number.Ln(b).
Examples
Example 3: Add a log-transformed revenue column to Sales
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Sales, 4), {"OrderID", "CustomerName", "UnitPrice"}),
"LnPrice",
each Number.Ln([UnitPrice]),
type number
)OrderID | CustomerName | UnitPrice | LnPrice | |
|---|---|---|---|---|
| 1 | 1 | Alice | 25 | 3.22 |
| 2 | 2 | Bob | 50 | 3.91 |
| 3 | 3 | Charlie | 15 | 2.71 |
| 4 | 4 | Alice | 75 | 4.32 |