calculate-column

Description

calculate-column adaptor applies one of the following mathematical operations using values in two columns in a datatable:

  • add: Adds values in left column to values in right column (left + right).

  • subtract: Subtract values in right column from values in left column (left - right).

  • multiply: Multiplies values in left column by values in right column (left * right).

  • divide: Divides values in left column by values in right column (left / right).

  • percent: Calculates the percentage ratio of values in left column out of values in right column (left / right * 100).

  • exponent: Calculates values in left column (raised) to the (power of) of values in right column (left ** right).

Inputs

data Type: datatable Required: Yes The datatable containing the column to be formatted.

left column Type: text Required: Yes The name of the column containing the values on the left-hand side of the operator.

right column Type: text Required: Yes The name of the column containing the values on the right-hand side of the operator.

operation Type: text Required: No The calculate operation to be used. Can be either add, subtract, multiply, divide, percent, or exponent. If unspecified, defaults to add.

result column Type: text Required: No The name of the column to which the calculated values will be added.

result unit Type: text Required: No An optional unit to be appended to the result. If unspecified, defaults to blank.

Outputs

data Type: datatable A datatable with formatted values.

Examples

Example 1: Default behaviour.

Inputs:

data:

Location
January case count
February case count

County X

27

15

County Y

58

80

left column: January case count

right column: February case count

Outputs:

  • data:

Location
January case count
February case count
result

County X

27

15

42

County Y

58

80

138

-> Added the values in January case count column to the values in February case count column. Results were displayed in a new column.

Example 2: Calculate percentage column.

Inputs:

data:

Month
Sales
Total

Jan

1458

14580

Feb

5832

14580

left column: Sales

right column: Total

result column: Percentage

result unit: %

Outputs:

  • data:

    Month
    Sales
    Total
    Percentage

    Jan

    1458

    14580

    10%

    Feb

    5832

    14580

    40%

-> Calculated the percentage ratio of values in Sales column out of values in Total column. The result was added to the Percentage column.

Last updated