Contents:
Each argument can be a Decimal or Integer literal or a reference to a column containing numeric values.
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:
pow(10,3)
Output: Returns the value of 10 3, which is 1000
.
Column reference example:
pow(MyValue,2)
Output: Returns the value of the MyValue
column raised to the power of 2 (squared).
Syntax and Arguments
pow(base_numeric_value, exp_numeric_value)
Argument | Required? | Data Type | Description |
---|---|---|---|
base_numeric_value | Y | string, decimal, or integer | Name of column or Decimal or Integer literal that is the base value to be raised to the power of the second argument |
exp_numeric_value | Y | string, decimal, or integer | Name of column or Decimal or Integer literal that is the power to which to raise the base value |
For more information on syntax standards, see Language Documentation Syntax Notes.
base_numeric_value
Name of the column or numeric literal whose values are used as the bases for the exponential computation.
- Missing input values generate missing results.
- Literal numeric values should not be quoted.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference) or Integer or Decimal literal | 2.3 |
exp_numeric_value
Name of the column or numeric literal whose values are used as the power to which the base-numeric value is raised.
- Missing input values generate missing results.
- Literal numeric values should not be quoted.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | String (column reference) or Integer or Decimal literal | 5 |
Tip: For additional examples, see Common Tasks.
Examples
Example - Exponential functions
EXP
- ex . See EXP Function.LN
- natural logarithm of the above. See LN Function.LOG
- 10x. See LOG Function.POW
- XY. The value X raised to the power Y. See POW Function.
Source:
rowNum | X |
---|---|
1 | -2 |
2 | 1 |
3 | 0 |
4 | 1 |
5 | 2 |
6 | 3 |
7 | 4 |
8 | 5 |
Transformation:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | EXP (X) |
Parameter: New column name | 'expX' |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | LN (expX) |
Parameter: New column name | 'ln_expX' |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | LOG (X) |
Parameter: New column name | 'logX' |
Transformation Name | New formula |
---|---|
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 |
Example - Pythagorean Theorem
POW
and SQRT
functions work together to compute the hypotenuse of a right triangle using the Pythagorean theorem.POW
- X Y . In this case, 10 to the power of the previous one. See POW Function .SQRT
- computes the square root of the input value. See SQRT Function.
The Pythagorean theorem states that in a right triangle the length of each side (x,y) and of the hypotenuse (z) can be represented as the following:
z2 = x 2 + y 2
Therefore, the length of z can be expressed as the following:
z = sqrt(x 2 + y 2 )
Source:
The dataset below contains values for x and y:
X | Y |
---|---|
3 | 4 |
4 | 9 |
8 | 10 |
30 | 40 |
Transformation:
You can use the following transformation to generate values for z2.
NOTE: Do not add this step to your recipe right now.
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | (POW(x,2) + POW(y,2)) |
Parameter: New column name | 'Z' |
You can see how column Z is generated as the sum of squares of the other two columns, which yields z2.
Now, edit the transformation to wrap the value computation in a SQRT
function. This step is done to compute the value for z, which is the distance between the two points based on the Pythagorean theorem.
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | SQRT((POW(x,2) + POW(y,2))) |
Parameter: New column name | 'Z' |
Results:
X | Y | Z |
---|---|---|
3 | 4 | 5 |
4 | 9 | 9.848857801796104 |
8 | 10 | 12.806248474865697 |
30 | 40 | 50 |
This page has no comments.