Page tree



Contents:

The cloud-based version of Trifacta Wrangler is now available! Read all about it, and register for your free account.

Computes the positive or negative sign of a given numeric value. The value can be a Decimal or Integer literal, a function returning Decimal or Integer, or a reference to a column containing numeric values.
  • For positive values, this function returns 1.
  • For negative values, this function returns -1.
  • For the value 0, this function returns 0.

Basic Usage

Column reference example:

sign(MyInteger)

Output: Returns the sign of the value found in the MyInteger column.

Numeric literal example:

(sign(MyInteger) == -1)

Output: Returns true if the sign of the entry in the MyInteger column is -1

Syntax

sign(numeric_value)


ArgumentRequired?Data TypeDescription
numeric_valueYDecimal or Integer Decimal or Integer literal, function returning Decimal or Integer, or name of column to apply to the function

For more information on syntax standards, see Language Documentation Syntax Notes.

numeric_value

Numeric literal, function returning numeric literal, or name of the column containg values the sign of which are 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 TypeExample Value
YesString (column reference) or Integer or Decimal value-10.5

Examples

Example - Basic SIGN function

Source:

Your source data looks like the following, which measures coordinate distances from a fixed point on a grid:

XY
-24
-6.2-2
0-4.2
44
15-0.05

Transformation:

You can use the following transform to derive the sign values of these columns:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula sign(X)
Parameter: New column name 'signX'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula sign(Y)
Parameter: New column name 'signY'

Using these two columns, you can assign each set of coordinates into a quadrant. For ease of reading, the following has been broken into two separate tranformations:

Transformation Name Conditional column
Parameter: Condition type Case on custom conditions
Parameter: Case 01 - Condition (signX == 1) && (signY == -1)
Parameter: Case 01 - Value 'lower-right'
Parameter: Case 02 - Condition (signX == 1) && (signY == 1)
Parameter: Case 02 - Value 'upper-right'
Parameter: Default value 'line'
Parameter: New column name 'q1'

Transformation Name Conditional column
Parameter: Condition type Case on custom conditions
Parameter: Case 01 - Condition (signX == -1) && (signY == -1)
Parameter: Case 01 - Value 'lower-left'
Parameter: Case 02 - Condition (signX == -1) && (signY == 1)
Parameter: Case 02 - Value 'upper-left'
Parameter: Default value 'line'
Parameter: New column name 'q2'

Then, you can merge the two columns together:

Transformation Name Merge columns
Parameter: Columns q1,q2
Parameter: Separator ''
Parameter: New column name 'quadrant'

Results:

XYsignXsignYquadrant
-24-11upper-left
-6.2-2-1-1lower-left
0-4.20-1line
4411upper-right
15-0.051-1lower-right

Your Rating: Results: 1 Star2 Star3 Star4 Star5 Star 14 rates

This page has no comments.