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.

Basic Usage

Numeric literal example:

derive value: LOG(49, 7)

Output: Generates a column containing the value of 7x = 49, which evaluates to 2.

Column reference example:

derive value: LOG(MyValue, 5) as: 'log_MyValue'

Output: Generates the new log_MyValue column containing the exponent that raises 5 to yield the MyValue column.

Syntax

derive value: LOG(result_numeric_value, base_numeric_value)

ArgumentRequired?Data TypeDescription
result_numeric_valueYstring, decimal, or integerName of column or Decimal or Integer literal that is generated by the LOG function
base_numeric_valueYstring, decimal, or integerName of column or Decimal or Integer literal that serves as the base for computing the LOG function

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 TypeExample Value
YesString (column reference) or Integer or Decimal literal49

base_numeric_value

Name of the column or Integer literal that is used for the exponential calculation.

NOTE: 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 TypeExample Value
NoString (column reference) or Integer or Decimal literal7

Examples

Example - Exponential functions

The following example demonstrates how the exponential functions work together. These functions include the following:

Source:

rowNumX
1-2
21
30
41
52
63
74
85

Transform:

derive value: EXP (X) as: 'expX'

derive value: LN (expX) as: 'ln_expX'

derive value: LOG (X) as: 'logX'

derive value: POW (10,logX) as: 'pow_logX'


Results:

In the following, (null value) indicates that a null value is generated for the computation.

rowNumXexpXln_expXlogXpow_logX
1-20.1353352832366127-2(null value)(null value)
2-10.1353352832366127-0.9999999999999998(null value)(null value)
3010(null value)0
412.718281828459045101
527.389056098930649520.301029995663981141.9999999999999998
6320.08553692318766830.477121254719662443
7454.5981500331442340.60205999132796233.999999999999999
85148.4131591025765750.69897000433601874.999999999999999

Was this page helpful? Let us know how we did:

Send feedback about...

Google Cloud Dataprep Documentation