Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r095

D toc

Excerpt

Numeric operators enable you to generate new values based on a computation (e.g. 3 + 4).

For each expression, the numeric operator is applied from left to right:

Code Block
(left-hand side) (operator) (right-hand side)

These evaluations result in a numeric output, which can be an Integer or Decimal depending on the input values. The following operators are supported:

Operator NameSymbolExample ExpressionOutputNotes
add+

3 + 6

 

9 
subtract-

6 - 5

 

1 
multiply*

3 * 6

 

18 
divide/

25 / 5

 

5 
modulo%5 % 41Computes the remainder as an integer of the first parameter divided by the second parameter. Input parameters must be Integers, column references to Integers, or an expression that evaluates to an Integer.
powerpowpow(4,3)64Power is implemented as a function. see POW Function.
negate--myColumnopposite of the value in myColumnThis operator supports only one operand. Parenthetical references are supported. See the example below.

 

The above examples apply to integer values only. Below, you can review how the comparison operators apply to different data types. 

Usage

Numeric operators are used to perform numeric manipulations on columns of data, Integer or Decimal constants, or both. Typically, they are applied in evaluations of values or rows. 

Example data:

XY
21
64
710
100

Transformations:


D trans
RawWrangletrue
p03Value'add'
Typestep
WrangleTextderive type:single value:(X + Y) as: 'add'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(X + Y)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'subtract'
Typestep
WrangleTextderive type:single value:(X - Y) as: 'subtract'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(X - Y)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'multiply'
Typestep
WrangleTextderive type:single value:(X * Y) as: 'multiply'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(X * Y)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'divide'
Typestep
WrangleTextderive type:single value:(X / Y) as: 'divide'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(X / Y)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'modulo'
Typestep
WrangleTextderive type:single value:(X % Y) as: 'modulo'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(X % Y)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'power'
Typestep
WrangleTextderive type:single value: pow(X,Y) as: 'power'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuepow(X,Y)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'negativeXminusY'
Typestep
WrangleTextderive type:single value: -(X-Y) as: 'negativeXminusY'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value-(X-Y)
p03NameNew column name
SearchTermNew formula

Results:

Your output looks like the following. Below, (null value) indicates that a null value is generated for the computation.

XYaddsubtractmultiplydividemodulopowernegativeXminusY
21312202-1
64102241.521296-3
71017-3700.772824752493
10020100(null value)(null value)1-10

D s
snippetExamples

Info

NOTE: When a numeric operator is applied to a set of values, the type of data of each source value is re-inferred to match any literal values used on the other side of the expression. This method allows for more powerful comparisons.

In the following examples, values taken from the MySource column are re-typed to match the inferred data type of the other side of the expression.

add

Column TypeExample TransformationOutputNotes
Integer/Decimal

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource + 5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource + 5)
SearchTermNew formula

Generated values are sum of values in MySource column and the constant (5 or 2.5).

 

 
DatetimeYou cannot directly add Datetime values. You can use the DATEDIF function to generate the number of days difference between two date values. See DATEDIF Function.  
String

You cannot add strings together.

  • You can use the MERGE transform to concatenate columns of string values together. See Merge Transform.
  • You can use the ARRAYCONCAT function to concatenate multiple columns of array type together. See ARRAYCONCAT Function.

 

 

 

For computational purposes, all data types not previously listed in this table behave like strings.

subtact

Column TypeExample TransformationOutputNotes
Integer/Decimal

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource - 5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource - 5)
SearchTermNew formula

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource - 2.5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource - 2.5)
SearchTermNew formula

Generated values are difference between values in MySource   column and the constant (5 or 2.5). 
DatetimeYou cannot directly subtract Datetime values. You must use the DATEDIF function to generate the number of days difference between two date values. See DATEDIF Function.  
String

You cannot differentiate strings directly.

  • You can use the SUBSTRING function to locate one string within the other. If found, this function returns the index of the value in the source string where the substring is located. This index value can used as an input to the LEFT and RIGHT functions to remove the substring. See SUBSTRING Function.
 For computational purposes, all data types not previously listed in this table behave like strings.

 

 

multiply

Column TypeExample TransformationOutputNotes
Integer/Decimal

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource * 5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource * 5)
SearchTermNew formula

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource * 2.5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource * 2.5)
SearchTermNew formula

Generated values are the product of values in the MySource column and the constant (5 or 2.5). 
DatetimeN/A  
String

N/A

 

 

divide

Column TypeExample TransformationOutputNotes
Integer/Decimal

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource / 5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource / 5)
SearchTermNew formula

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource / 2.5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource / 2.5)
SearchTermNew formula

Generated values are the values in the MySource column divided by the constant (5 or 2.5).

 

 
DatetimeN/A  
String

N/A

 

 


modulo

Column TypeExample TransformationOutputNotes
Integer

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource % 5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource % 5)
SearchTermNew formula

Generated values are the values in the MySource column divided by the constant (5 or 2.5).

 

 
Decimal

D trans
RawWrangletrue
Typestep
WrangleTextderive type:single value:(MySource % 2.5)
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Value(MySource % 2.5)
SearchTermNew formula

Not supported. Inputs must be of Integer type. 
DatetimeN/A  
String

N/A

 

 

D s also
labelmath