---
schema_version: "1"
id: 642c453ac0b0f6d3ea8afb3c2a19146112e41259315bd6b2816f35a66000e006
title: Math Functions
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/reference/bi-saql-functions-math.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 294af28776d08434203edabad3173020f3808a9ed4533cf250959e060d12fdce
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# 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 math functions in a `group by` clause or in an `order by` clause. You also can't use math functions in the `filter by` clause before a `foreach` statement.

- **[abs(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-abs.md)**


    Returns the absolute number of _n_ as a numeric value. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. This function can only be used in a `foreach` statement.

- **[acos(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-acos.md)**


    Returns the arccosine value of radians value _n_. _n_ can be any real numeric value in the range of -1 \<= _n_ \<= 1. If `null` is passed as an argument, `acos()` returns `null`. This function can only be used in a `foreach` statement.

- **[asin(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-asin.md)**


    Returns the arcsine value of radians value _n_. _n_ can be any real numeric value in the range of -1 \<= _n_ \<= 1. If `null` is passed as an argument, `asin()` returns `null`.This function can only be used in a `foreach` statement.

- **[atan(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-atan.md)**


    Returns the arctangent value of radians value _n_. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `atan()` returns `null`. This function can only be used in a `foreach` statement.

- **[ceil(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-ceil.md)**


    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. This function can only be used in a `foreach` statement.

- **[cos(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-cos.md)**


    Returns the cosine value of radians value _n_. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `cos()` returns `null`. This function can only be used in a `foreach` statement.

- **[degrees(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-degrees.md)**


    Returns the degrees value of a radians value _n_. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `degrees()` returns `null`. This function can only be used in a `foreach` statement.

- **[exp(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-exp.md)**


    Returns the value of Euler's number _e_ raised to the power of _n_, where _e_ = 2.71828183… The smallest value for _n_ that doesn’t result in 0 is 3e-324. _n_ can be any real numeric value in the range of -1e308 \<= n \<= 700. This function can only be used in a `foreach` statement.

- **[floor(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-floor.md)**


    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. This function can only be used in a `foreach` statement.

- **[log(m, n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-log.md)**


    Returns the natural logarithm (base m) of a number _n_. The values _m_ and _n_ can be any positive, non-zero numeric value in the range 0 \< m, n \<= 1e308 and m ≠ 1. The smallest value for _m_ or _n_ that will not produce 0 is log(10, 0.3e-323). This function can only be used in a `foreach` statement.

- **[pi()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-pi.md)**


    Returns the value of π, where π=3.14139265. This function can only be used in a `foreach` statement.

- **[power(m, n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-power.md)**


    Returns _m_ raised to the _n_th power. _m_, _n_ can be any numeric value in the range of -1e308 \<= _m_, _n_ \<= 1e308. Returns `null` if _m_ = 0 and _n_ \< 0. This function can only be used in a `foreach` statement.

- **[radians(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-radians.md)**


    Returns the radians value of a degrees value _n_. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `radians()` returns `null`. This function can only be used in a `foreach` statement.

- **[round(n[, m])](bi-saql-functions-math-round.md)**


    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. This function can only be used in a `foreach` statement.

- **[sign(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-sign.md)**


    Returns 1 if the numeric value, _n_ is positive. It returns -1 if the _n_ is negative, and 0 if _n_ is 0. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `sign()` returns `null`. This function can only be used in a `foreach` statement.

- **[sin(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-sin.md)**


    Returns the sine value of radians value _n_. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `sin()` returns `null`. This function can only be used in a `foreach` statement.

- **[sqrt(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-sqrt.md)**


    Returns the square root of a number _n_. The value _n_ can be any non-negative numeric value in the range of 0 \<= _n_ \<= 1e308. This function can only be used in a `foreach` statement.

- **[tan(n)](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-math-tan.md)**


    Returns the tangent value of radians value _n_. _n_ can be any real numeric value in the range of -1e308 \<= _n_ \<= 1e308. If `null` is passed as an argument, `tan()` returns `null`. This function can only be used in a `foreach` statement.

- **[trunc(n[, m])](bi-saql-functions-math-trunc.md)**


    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. This function can only be used in a `foreach` statement.
