On January 27, 2021, Google is changing the required permissions for attaching IAM roles to service accounts. If you are using IAM roles for your Google service accounts, please see Changes to User Management.
Computes the absolute value of a given numeric value. The value 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
Column reference example:
abs(MyInteger)
Output: Returns the absolute value of each value found in the MyInteger
column.
Numeric literal example:
(abs(MyInteger) == 5)
Output: Returns true
if the absolute value of the entry in the MyInteger
column is 5.
Syntax and Arguments
abs(numeric_value)
Argument | Required? | Data Type | Description |
---|---|---|---|
numeric_value | Y | string, decimal, or integer | Name of column or Decimal or Integer literal to apply to the function |
For more information on syntax standards, see Language Documentation Syntax Notes.
numeric_value
Name of the column or numeric literal whose absolute value is to be computed.
- 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 value | -10.5 |
Tip: For additional examples, see Common Tasks.Examples
Example - Basic ABS function
Source:
Your source data looks like the following, which measures coordinate distances from a fixed point on a grid:
X | Y |
---|---|
-2 | 4 |
-6.2 | -2 |
0 | -4.2 |
4 | 4 |
15 | -0.05 |
Transform:
You can use the following transform to derive the absolute values of these columns, which now measure distance from the fixed point:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | abs(X) |
Parameter: New column name | 'distanceX' |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | abs(y) |
Parameter: New column name | 'distanceY' |
Results:
X | Y | distanceX | distanceY |
---|---|---|---|
-2 | 4 | 2 | 4 |
-6.2 | -2 | 6.2 | 2 |
0 | -4.2 | 0 | 4.2 |
4 | 4 | 4 | 4 |
15 | -0.05 | 15 | 0.05 |
You can then use POW
and SQRT
functions to compute the total distance.
This page has no comments.