LOG Function
Computes the logarithm of the first argument with a base of the second argument.
First argument can be a Decimal or Integer literal or a reference to a column containing numeric values.
Second argument, the base, must be an Integer value or column reference.
Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.
Basic Usage
Numeric literal example:
log(49, 7)
Output: Returns 2
.
Column reference example:
log(MyValue, 5)
Output: Returns the exponent that raises 5 to yield the MyValue
column.
Syntax and Arguments
log(result_numeric_value, base_numeric_value)
Argument | Required? | Data Type | Description |
---|---|---|---|
result_numeric_value | Y | string, decimal, or integer | Name of column or Decimal or Integer literal that is generated by the |
base_numeric_value | Y | string, decimal, or integer | Name of column or Decimal or Integer literal that serves as the base for computing the |
For more information on syntax standards, see Language Documentation Syntax Notes.
result_numeric_value
Name of the column or numeric literal. Value must be greater than 0.
Missing input values generate missing results.
Literal numeric values should not be quoted. Quoted values are treated as strings.
Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference) or Integer or Decimal literal | 49 |
base_numeric_value
Name of the column or Integer literal that is used for the exponential calculation.
注意
This base value must be a positive integer. If this value is not specified, 10
is used as the base value.
Missing input values generate missing results.
Literal numeric values should not be quoted. Quoted values are treated as strings.
Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
No | String (column reference) or Integer or Decimal literal | 7 |
Examples
提示
For additional examples, see Common Tasks.
Example - Exponential functions
This example demonstrates the exponential functions.
Functions:
Item | Description |
---|---|
EXP Function | Computes the value of e raised to the specified power. The value can be a Decimal or Integer literal or a reference to a column containing numeric values. |
LN Function | Computes the natural logarithm of an input value. The value can be a Decimal or Integer literal or a reference to a column containing numeric values. |
LOG Function | Computes the logarithm of the first argument with a base of the second argument. |
POW Function | Computes the value of the first argument raised to the value of the second argument. |
Source:
rowNum | X |
---|---|
1 | -2 |
2 | 1 |
3 | 0 |
4 | 1 |
5 | 2 |
6 | 3 |
7 | 4 |
8 | 5 |
Transformation:
Transformation Name | |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | EXP (X) |
Parameter: New column name | 'expX' |
Transformation Name | |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | LN (expX) |
Parameter: New column name | 'ln_expX' |
Transformation Name | |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | LOG (X) |
Parameter: New column name | 'logX' |
Transformation Name | |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | POW (10,logX) |
Parameter: New column name | 'pow_logX' |
Results:
In the following, (null value)
indicates that a null value is generated for the computation.
rowNum | X | expX | ln_expX | logX | pow_logX |
---|---|---|---|---|---|
1 | -2 | 0.1353352832366127 | -2 | (null value) | (null value) |
2 | -1 | 0.1353352832366127 | -0.9999999999999998 | (null value) | (null value) |
3 | 0 | 1 | 0 | (null value) | 0 |
4 | 1 | 2.718281828459045 | 1 | 0 | 1 |
5 | 2 | 7.3890560989306495 | 2 | 0.30102999566398114 | 1.9999999999999998 |
6 | 3 | 20.085536923187668 | 3 | 0.47712125471966244 | 3 |
7 | 4 | 54.59815003314423 | 4 | 0.6020599913279623 | 3.999999999999999 |
8 | 5 | 148.41315910257657 | 5 | 0.6989700043360187 | 4.999999999999999 |