log
Description
Returns the logarithm of a number to a specified base. Common uses include modeling compound interest, exponential growth or decay, pH levels, and earthquake magnitudes.
Syntax
Like many functions in DataPrime, log supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.
- Function notation
- Method notation
log(base: number, number: number): number
(base: number).log(number: number): number
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
base | number | true | The logarithmic base (e.g. 2 for log base 2) |
number | number | true | The value whose logarithm will be computed |
Example
Use case: Compute a log base 2 transformation
Calculate the log base 2 of a numerical field and store the result in a new field.
Example data
{
"some_value": 16
}
Example query
- Function notation
- Method notation
create log_field from log(2, some_value)
create log_field from 2.log(some_value)
Example output
{
"some_value": 16,
"log_field": 4
}