Returns the logarithm of a positive number.
The mathematical base that the LOG function uses depends on the following factors:
If the underlying dataset can perform the calculation, then the LOG function uses base-e.
LOG uses base 2 whenever Data Studio performs the calculation itself instead of letting the underlying dataset run the calculation. For example, Data Studio calculates the formula itself in the
following situations:
- You use
LOGin a calculated field on a data source that doesn't support performing the calculation, such as Bigtable or Google Ads. - You use
LOGin a calculated field on a blended data source, even when the original data sources use base-e connectors. - Your formula combines
LOGwith a function that the underlying data source doesn't support directly, such asLOG(MEDIAN(Price))on Spanner.
The following table summarizes the connectors and situations that use base-e and base-2:
| Connectors that use Base e (natural logarithm) | Connectors and situations that use Base 2 |
|---|---|
|
|
Calculate a logarithm with a custom base
For base-10 logarithms, use the LOG10 function,
which uses base 10 across all connectors.
To calculate a logarithm with a
consistent custom base B across any connector or blend, use the
change-of-base formula:
LOG10(X) / LOG10(B).
For example, use
LOG10(X) / LOG10(2.718281828459045) for base e or
LOG10(X) / LOG10(2) for base 2.
Sample usage
LOG(256)
Syntax
LOG( X )
Parameters
X: a positive number, field, or expression that evaluates to a positive number.
Examples
The following table compares LOG outputs for base-e and base-2 connectors:
| Example formula | Input | Base-e output | Base-2 output |
|---|---|---|---|
LOG(My field) |
1 | 0 | 0 |
LOG(My field) |
2.718281828459045 | 1 | 1.442695041 |
LOG(My field) |
128 | 4.852030264 | 7 |