Newer Version Available
Math Functions
To perform numeric operations in a SAQL query, use math
functions.
You can use SAQL math functions in foreach statements and in the filter by clause after a foreach statement.
You can’t use SAQL math functions in group by or order by clauses, or in the filter by clause before a foreach statement.
Functions
This table lists the SAQL math functions:
| Function | Description |
|---|---|
| ABS(n) | Returns the absolute number of n as a
numeric value. n can be any real numeric
value in the range of -1e308 <= n <=
1e308. These examples are
valid:
These
examples are
invalid:
|
| CEIL(n) | Returns the nearest integer of equal or greater value to
n. n can be any real
numeric value in the range of -1e308 <= n <=
1e308. These examples are
valid:
These
examples are
invalid:
|
| FLOOR(n) | Returns the nearest integer of equal or lesser value to
n. n can be any real
numeric value in the range of -1e308 <= n <=
1e308. These examples are
valid:
These
examples are
invalid:
|
| TRUNC(n[, m]) | Returns the value of the numeric expression
n truncated to m
decimal places. m can be negative, in which
case the function returns n truncated to
-m places to the left of the decimal
point. If m is omitted, it returns
n truncated to the integer place.
n can be any real numeric value in the
range of -1e308 <= n <= 1e308. m can be
an integer value between -15 and 15 inclusive. These examples
are
valid:
These
examples are
invalid:
|
| ROUND(n[, m]) | Returns the value of n rounded to
m decimal places. m
can be negative, in which case the function returns
n rounded to -m places
to the left of the decimal point. If m is
omitted, it returns n rounded to the nearest
integer. For tie-breaking, it follows round half way from zero
convention. n can be any real numeric value
in the range of -1e308 <= n <= 1e308. m
can be an integer value between -15 and 15, inclusive. These
examples are
valid:
These
examples are
invalid:
|