doo.functions.math

 

Basic mathematical functions that can also be used in a Calculated field type.

Round

Mathematically round a decimal number to specified number of decimal places (solves JavaScript rounding inaccuracy). E.g. round(2.494, 2) = 2.49, round(2.495, 2) = 2.5, round(1.006, 2) = 1.01, round(1.015, 2) = 1.02, round(1.045, 2) = 1.05

Example

const x = doo.functions.math.round(2.494, 2);
doo.model.number.value = x; // 2.49

MIN

Returns the lowest number.

Example

const x = doo.functions.math.min(-50, 0, 20);
doo.model.number.value = x; // -50

MAX

Returns the largest number.

Example

const x = doo.functions.math.max(-50, 0, 20);
doo.model.number.value = x; // 20

AVG

Returns the average.

Example

const x = doo.functions.math.avg(-50, 0, 20);
doo.model.number.value = x; // -10

ABS

Return the absolute value.

Example

const x = doo.functions.math.abs(-50);
doo.model.number.value = x; // 50

ROUNDUP

Returns number rounded up.

Example

const x = doo.functions.math.roundUp(2.44, 1);
doo.model.number.value = x; // 2.5

ROUNDDOWN

Returns number rounded down.

Example

const x = doo.functions.math.roundDown(2.44, 1);
doo.model.number.value = x; // 2.4

PERCENTAGE

Numerator/Denominator * 100, Parameters 10, 50 gives 20 (percents)

Example

const x = doo.functions.math.percentage(10,50);
doo.model.number.value = x; // 20

Was this article helpful?