Number.Ln

Number

Returns the natural logarithm (base e) 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.Ln(number as nullable number) as nullable number

Parameters

NameTypeRequiredDescription
numbernumberYesThe number whose natural logarithm is computed. Must be positive for a real result.

Return Value

numberThe 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 1: Natural log of e returns 1

Result
Result
11

Example 2: Natural log of 1 returns 0

Result
Result
10

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
)
Result
OrderID
CustomerName
UnitPrice
LnPrice
11Alice253.22
22Bob503.91
33Charlie152.71
44Alice754.32

Compatibility

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