> For the complete documentation index, see [llms.txt](https://docs.phocassoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md).

# Use functions in calculations

Learn about the inbuilt functions you can use when entering formulas in calculation columns.

{% hint style="info" %}
Flex Modes is now Analytics in the new experience. [Understand the changes](https://docs.phocassoftware.com/analytics/understand-the-analytics-changes.md)
{% endhint %}

This page describes the inbuilt functions you can use when entering formulas in calculation columns in Analytics.

### ABS

`ABS(value)`

Returns the absolute value of a number. Positive numbers and 0 remain unchanged. Negative numbers are returned as positive numbers.

**Input**

`value`: The number or column to evaluate.

**Examples**

1. `ABS(-2)` returns `2`.
2. In the image below, the **ABS** calculation column uses `ABS(Sep 2026, Value)` to return the absolute value of each number in the **Sep 2026 Value** column.

   In rows 1 and 2, `-647.95` and `-6.06` become `647.95` and `6.06`. Positive values, such as `14.97` in row 3, remain unchanged.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2F7DtKYyrpgcieAmSKlAgq%2Fimage.png?alt=media&amp;token=7b2ee392-1d38-4fee-bd7a-5cff042b566a" alt=""><figcaption></figcaption></figure>

### AND

`AND(value1, value2)`

Returns **TRUE** when all conditions are TRUE. If any condition is FALSE, it returns **FALSE**. Commonly used with the `IF` function.

**Inputs**

* `value1`: The first condition to evaluate.&#x20;
* `value2…`: Optional additional conditions.&#x20;

Each condition must return a value that `AND` can evaluate as TRUE or FALSE. `AND` treats 0 as FALSE and any nonzero value, including a negative value, as TRUE.

**Examples**

1. `AND(1, 1)` returns `1` (TRUE) because both values are nonzero. `AND(1, 0)` returns `0` (FALSE) because one value is 0.
2. In the image below, the **AND** calculation column uses `AND(IF(W35 2026, Value > 0, 1, 0), IF(W36 2026, Value > 0, 1, 0))` to check whether the **W35 2026** and **W36 2026** values are both greater than 0. Each `IF` function returns `1` when its column's value is greater than 0 and `0` when it isn't. The `AND` function then evaluates these results.

   In rows 6 and 9, W36 2026 is empty, so its `IF` function returns 0. As a result, `AND` returns **0**. In all other rows, both `IF` functions return 1, so `AND` returns **1**.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FaqRkwNQB0WFenaIfyds0%2Fimage.png?alt=media&amp;token=2e08492a-69a0-4b68-a238-2c32a73fea84" alt=""><figcaption></figcaption></figure>

### ARRAY

`ARRAY(value1, [value2…])`

Groups one or more values into a single, ordered list. Commonly used as an input in other functions that require a series of values, such as `FORECAST.LINEAR` or `PERCENTILE`.

**Inputs**

* `value1`: The first value or column within the list.&#x20;
* `[value2…]`: Optional additional values or columns to add to the list.

**Examples**

1. `ARRAY(1)` returns an array containing one value: `[1]`.
2. `ARRAY(1, 2, 3)` returns an array containing three values: `[1, 2, 3]`.
3. See the [FORECAST.LINEAR example](https://docs.phocassoftware.com/pages/PQKGzt9UJBskqKpbQEsQ#forecast.linear) for how to use ARRAY with quarterly columns to predict the next quarter's value.
4. See the [PERCENTILE example](https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md#percentile) for how to use ARRAY to group column values into a series and calculate a percentile.

### AVERAGE

`AVERAGE(value1, [value2…])`

Returns the average of a series of numbers.

**Inputs**

* `value1`: The first value, column, or column range to include in the average.
* `[value2…]`: Optional additional values, columns, or column ranges to include in the average.

**Examples**

1. `AVERAGE(1, 2, 3)` returns `2`.
2. In the image below, the **Average** calculation uses `AVERAGE(Aug 2026 Value, Sept 2026 Value, Oct 2026 Value)` to calculate the average of the three monthly values in each row.

   In row 1, the values are `87,109.72`, `91,837.45`, and `90,439.36`. Their average is `89,795.51`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FHi95Zfp7qy29uicxcj7K%2Fimage.png?alt=media&amp;token=9e6edca8-da13-455a-9b44-6f7820dbdf88" alt=""><figcaption><p><em>Read the results in the <strong>Average</strong> column under <strong>Oct 2026</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>
3. In the image below, the **Average** calculation uses `AVERAGE(2026-Q1 - 2026-Q4, 2025-Q1 - 2025-Q4)` to calculate the average of the 2026 and 2025 annual values in each row.

   In row 1, `534,050.61` and `749,014.66` give an average of `641,532.64`. This averages the two annual values, rather than the individual quarterly values.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FvYEKeGw4s2DiuUTeboNZ%2Fimage.png?alt=media&amp;token=7973c8ad-03f0-41ad-a521-11d23f40c39a" alt=""><figcaption></figcaption></figure>

### COALESCE

`COALESCE(value1, [value2…])`

Returns the first non-empty value from a series of values, checking them in the order specified in the formula.

Use COALESCE when you want to use a value from one column but fall back to another column if the first is empty. For example, you can use a value from one period and fill gaps with values from another period. The source columns remain unchanged.

**Inputs**

* `value1`: The first value or column to check.
* `[value2…]`: Optional additional values or columns to check, in order.

**Examples**

1. `COALESCE([null, null, 1, 4, null])` returns `1`, the first non-empty value.
2. In the image below, the **Coalesce** calculation uses `COALESCE(Jan 2025 - Nov 2025, Jan 2026 - Nov 2026)` to return the 2025 value when available and use the 2026 value when the 2025 cell is empty.

   In row 1, the result is `417,169.02` from 2025. In row 5, the 2025 cell is empty, so the result is `415,750.24` from 2026. The order of the references in the formula determines which value is used, regardless of the columns' positions in the grid.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2F9pRATXMmpj4fuc9FFNwh%2Fcoalesce-period-fallback.png?alt=media" alt="COALESCE returns the 2025 value, with the 2026 value used for the empty 2025 cell in row 5."><figcaption></figcaption></figure>

### DAYS

`DAYS(coordinate)`

Returns the number of days in a period or period range, including weekends.

Use `DAYS` when a calculation depends on the number of days in a period, such as calculating a daily cost over a period.

**Input**

`coordinate`: The period or period range to calculate the number of days for. You must specify a period. Leaving the input empty returns an error.

**Examples**

1. `DAYS(Jun 2024)` returns `30`, the number of days in June 2024.
2. `DAYS(Jul 2025 - Dec 2025)` returns `184`, the number of days from July to December 2025.
3. In the image below, the **Days in period** calculation uses `DAYS(01/09/2026 - 05/11/2026)` to return `66`, the number of days from September 1 to November 5, 2026, including both dates and weekends.

   Every row returns the same result because `DAYS` counts the days in the column's period, regardless of the values in each row.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FMrlOFkJxdLLiB0C5ca0Q%2Fdays-custom-period.png?alt=media" alt="DAYS returns 66 for the period September 1 to November 5, 2026."><figcaption></figcaption></figure>

### FINITE

`FINITE(value, fallback, [-infinity], [+infinity])`

Returns the original value if it is finite. If it is NaN (not a number), negative infinity, or positive infinity, returns the specified fallback value.

Use `FINITE` to replace non-finite calculation results with a value you choose, such as 0 when a calculation divides by zero.

**Inputs**

* `value`: The number, column, or calculation to check.
* `fallback`: The value to return for any non-finite result when using two inputs. When using four inputs, this is the value returned for NaN.
* `[-infinity]`: The value returned for -infinity.
* `[+infinity]`: The value returned for +infinity.

Use two inputs to return the same fallback for all non-finite results. Use four inputs to return different values for NaN, negative infinity, and positive infinity, in that order.

**Examples**

1. `FINITE(1/0, 0)` returns `0` because dividing 1 by 0 produces a non-finite result.
2. `FINITE(-1/0, 1, 2, 3)` returns `2`, the value defined for -infinity.
3. `FINITE(NaN, 0)` returns `0`.
4. In the image below, the **FINITE** calculation uses `FINITE(Sep 2026 Value / 0, 0)`. Each value in the **Sep 2026 Value** column is divided by 0, producing a non-finite result. The fallback is `0`, so every row displays `0.00`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FnJHkvUTtpAbmwOnXjVYy%2Ffinite-fallback.png?alt=media" alt="FINITE replaces each non-finite result of dividing the Sep 2026 Value column by zero with 0."><figcaption></figcaption></figure>

### FORECAST.LINEAR

`FORECAST.LINEAR(position, series)`

Predicts a value at a given position in a series using linear regression, which fits a straight line to the known values.

**Inputs**

* `position`: The position in the series to calculate the predicted value for. Positions start at 1. For example, use 5 to predict the next value after four known values.
* `series`: The known values to use for the linear regression. Create the series with the `ARRAY` function or a range of columns.

**Examples**

1. `FORECAST.LINEAR(5, ARRAY(100, 200, 300, 400))` returns `500`. `ARRAY` supplies the four known values. Position `5` predicts the next value in the series.
2. In the image below, the **Next quarter prediction** calculation uses `FORECAST.LINEAR(5, ARRAY(2026-Q1 Value, 2026-Q2 Value, 2026-Q3 Value, 2026-Q4 Value))` to predict Q1 2027 from the four quarterly values for 2026. The total prediction is `432,445.03`, rounded to two decimal places.

   `ARRAY` supplies the four **Value** columns in order, from **2026-Q1** to **2026-Q4**. Position `5` predicts the next quarter. Each row uses its own quarterly values to calculate its prediction.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FEnvv28zRrVrCyJopqhif%2Fimage.png?alt=media&amp;token=b9ad2d2e-9ec5-40af-947f-feba889d1397" alt=""><figcaption><p><em>Read the results in the <strong>Next quarter prediction</strong> column under <strong>2026-Q4</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>

### IF

`IF(logical expression, value if true, value if false)`

Returns one value when a condition is TRUE and another value when it is FALSE.

A logical expression is a statement that evaluates to either TRUE or FALSE.

**Inputs**

* `logical expression`: A statement that evaluates to either TRUE or FALSE.
* `value if true`: The value returned if the logical expression is TRUE.
* `value if false`: The value returned if the logical expression is FALSE.

Use this function for if-then-else logic, such as setting a sales-based discount threshold.

**Examples**

1. In the image below, the **IF** calculation uses `IF(Sep 2026 Value > 0, 1, 0)` to return `1` when the value is greater than 0. If the value is zero or less, it returns `0`.

   In row 1, the value is `-6.26`, so the result is `0`. In row 6, the value is `7.34`, so the result is `1`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FfW76nxqUD1LVypawnayE%2Fif-positive-values.png?alt=media" alt="IF returns 0 for negative Sep 2026 values and 1 for positive values."><figcaption></figcaption></figure>
2. `IF(Sales > 7000000, Sales * 0.05, 0)` returns 5% of sales when sales exceed 7 million. Otherwise, it returns `0`.
3. See the [NOT example](https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md#not) for how to use IF with NOT to flag counts that differ from an expected value.
4. See the [AND example](https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md#and) for how to use IF with AND to check whether both weekly values are greater than 0.
5. See the [OR example](https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md#or) for how to use IF with OR to check whether at least one weekly value is greater than 0.

### MAX

`MAX(value1, [value2…])`

Returns the largest number in a set of values. When you reference multiple columns, it compares the values in each row and returns the largest value for that row.

Use `MAX` to find the highest value across periods or measures. For example, compare monthly sales columns to find each customer's highest monthly sales value over a selected period.

**Inputs**

* `value1`: The first value, column, or column range to compare.
* `[value2…]`: Optional additional values, columns, or column ranges to compare.

**Examples**

1. `MAX(-2, 5, 10)` returns `10`.
2. `MAX(Jul 2025 .. Dec 2025)` returns the largest value in the range from July to December 2025.
3. In the image below, the **Max** calculation uses `MAX(Aug 2026 Value, Sept 2026 Value, Oct 2026 Value)` to find each customer's highest monthly sales value across August, September, and October 2026.

   In row 1, the monthly values are `65,300.17`, `91,005.30`, and `89,560.44`. The result is `91,005.30`, the September value.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FZIv7caxIN3YkSYEYkUhh%2Fmax-monthly-sales.png?alt=media" alt="MAX compares monthly sales from August to October 2026. Read the Max results under Aug 2026."><figcaption><p><em>Read the results in the <strong>Max</strong> column under <strong>Aug 2026</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>

### MIN

`MIN(value1, [value2…])`

Returns the smallest number in a set of values. When you reference multiple columns, it compares the values in each row and returns the smallest value for that row.

Use `MIN` to find the lowest value across periods or measures. For example, compare monthly sales columns to find each customer's lowest monthly sales value over a selected period.

**Inputs**

* `value1`: The first value, column, or column range to compare.
* `[value2…]`: Optional additional values, columns, or column ranges to compare.

**Examples**

1. `MIN(-2, 5, 10)` returns `-2`.
2. `MIN(Jul 2025 .. Dec 2025)` returns the smallest value in the range from July to December 2025.
3. In the image below, the **Min** calculation uses `MIN(Aug 2026 Value, Sept 2026 Value, Oct 2026 Value)` to find each customer's lowest monthly sales value across August, September, and October 2026.

   In row 1, the monthly values are `65,300.17`, `91,005.30`, and `89,560.44`. The result is `65,300.17`, the August value.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FNux6u1FfGtWZnTGxMuNt%2Fmin-monthly-sales.png?alt=media" alt="MIN compares monthly sales from August to October 2026. Read the Min results under Aug 2026."><figcaption><p><em>Read the results in the <strong>Min</strong> column under <strong>Aug 2026</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>

### NOT

`NOT(condition1, [condition2…])`

Reverses a logical result: TRUE becomes FALSE and FALSE becomes TRUE. Commonly used with the `IF` function.

Use `NOT` to flag values that do not meet a condition, such as counts that differ from an expected value.

**Inputs**

* `condition1`: The first condition or value to evaluate.
* `[condition2…]`: Optional additional conditions or values to evaluate.

`NOT` treats 0 as FALSE and any nonzero value, including a negative value, as TRUE. It returns `1` for TRUE and `0` for FALSE.

**Examples**

1. `NOT(1)` returns `0` (FALSE). `NOT(0)` returns `1` (TRUE).
2. In the image below, the **NOT** calculation uses `NOT(IF(W35 2026 Count = 4, 1, 0))` to flag counts that differ from an expected value of 4.

   In row 1, **Count** is `4`, so `IF` returns `1` (TRUE). `NOT` reverses this to `0` (FALSE). In row 6, **Count** is `3`, so `IF` returns `0` (FALSE). `NOT` reverses this to `1` (TRUE).

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FlKjcv2X9oZqjRAqK0IpT%2Fnot-expected-count.png?alt=media" alt="NOT flags W35 2026 counts that differ from 4. Row 1 returns 0 and row 6 returns 1."><figcaption></figcaption></figure>

### OR

`OR(condition1, condition2, [condition3]…)`

Returns TRUE when at least one condition is TRUE, including when all conditions are TRUE. If all conditions are FALSE, it returns FALSE. Commonly used with the `IF` function.

Use `OR` to flag rows that meet at least one of several conditions. For example, identify customers with positive sales in either of two weeks.

**Inputs**

* `condition1`: The first condition or value to evaluate.
* `condition2`: The second condition or value to evaluate.
* `[condition3…]`: Optional additional conditions or values to evaluate.

`OR` treats 0 as FALSE and any nonzero value, including a negative value, as TRUE. It returns `1` for TRUE and `0` for FALSE.

**Examples**

1. `OR(1, 0)` returns `1` (TRUE) because at least one value is nonzero. `OR(0, 0)` returns `0` (FALSE) because both values are 0.
2. In the image below, the **OR** calculation uses `OR(IF(W35 2026 Value > 0, 1, 0), IF(W36 2026 Value > 0, 1, 0))` to check whether at least one of the two weekly values is greater than 0. Each `IF` function returns `1` when its column's value is greater than 0 and `0` otherwise.

   In rows 1 and 4, both weekly values are greater than 0, so `OR` returns `1`. In rows 2, 3, 5, and 6, only one weekly value is greater than 0, so the result is also `1`. In rows 7 to 10, neither weekly value is greater than 0, so the result is `0`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FyvS7ANV5sS6RGDjgYbis%2For-positive-weekly-values.png?alt=media" alt="OR returns 1 when W35 2026 or W36 2026 Value is greater than zero. Rows 7 to 10 return 0."><figcaption></figcaption></figure>

### PERCENTILE

`PERCENTILE(series, k)`

Returns the value at a specified percentile in a series of numbers. The result can fall between values in the series.

Use `PERCENTILE` to calculate a benchmark from a set of values. For example, use `0.5` with monthly sales columns to find each customer's median monthly sales value.

**Inputs**

* `series`: The values or columns to evaluate, grouped using the `ARRAY` function.
* `k`: The percentile to calculate, expressed as a number from 0 to 1, inclusive. For example, `0.3` represents the 30th percentile and `0.5` represents the 50th percentile (the median).

**Examples**

1. `PERCENTILE(ARRAY(1, 2, 3, 4), 0.3)` returns `1.9`, the 30th percentile of the series. `PERCENTILE(ARRAY(1, 2, 3, 4), 0.5)` returns `2.5`, the 50th percentile (the median).
2. In the image below, the **PERCENTILE** calculation uses `PERCENTILE(ARRAY(Sep 2026 1, Sep 2026 2, Sep 2026 3, Sep 2026 4), 0.3)`. The calculation columns named **1**, **2**, **3**, and **4** contain those numbers in each row. `ARRAY` groups the four column values into the series, and `0.3` specifies the 30th percentile.

   Read the **PERCENTILE** results in the individual rows, where the result is `1.90`. Changing the second input to `0.5` would return `2.50`. The total row displays `#ERR` in this screenshot.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FfwXyufAxG4nCZFpsuDtR%2Fpercentile-array-example.png?alt=media" alt="PERCENTILE uses ARRAY to group columns containing 1, 2, 3, and 4. The 30th percentile is 1.90 in each detail row."><figcaption></figcaption></figure>

### PERIODCOUNT

`PERIODCOUNT(column)`

Returns the number of periods, such as months or days, associated with a column.

Use `PERIODCOUNT` when a calculation depends on how many periods a column covers, such as calculating an average value per month.

**Input**

`column`: The transaction column to find the period for.

**Example**

In the image below, the **PERIODCOUNT** calculation uses `PERIODCOUNT(Oct 2025 - Sep 2026)` to return `12`. The selected column covers October 2025 to September 2026 and contains 12 monthly periods.

Every row displays `12.00` because the number of periods depends on the column's period range, rather than the values in each row.

<figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FjXUuUAFezUZ3cr9soyet%2Fperiodcount-monthly-periods.png?alt=media" alt="PERIODCOUNT returns 12 for the 12 monthly periods from October 2025 to September 2026."><figcaption></figcaption></figure>

### POWER

`POWER(base, exponent)`

Returns a number raised to a power.

Use `POWER` to calculate repeated growth. For example, if a quantity doubles each period, `POWER(2, 3)` gives a growth factor of 8 after three periods. Multiply the starting quantity by this factor to calculate the final quantity.

**Inputs**

* `base`: The number or column to raise to a power.
* `exponent`: The power to raise the base to.

**Examples**

1. `POWER(2, 3)` returns `8`, because 2 raised to the power of 3 is `2 × 2 × 2 = 8`.
2. In the image below, the **POWER** calculation uses `POWER(Sep 2026 2, 3)` to raise each value in the calculation column named **2** to the power of 3. Each row contains `2.00`, so every result is `8.00`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FHzagbwpfvvsjNAgyEkzk%2Fpower-column-example.png?alt=media" alt="POWER raises each value of 2 in the Sep 2026 calculation column to the power of 3 and returns 8.00."><figcaption></figcaption></figure>

### RANK

`RANK(value, [series])`

Assigns a rank to a value based on how large it is compared to other values. The largest value receives rank `1`.

Use `RANK` to compare performance. For example, rank customers by sales within a column, or see how a customer's sales for one month compare with their sales in other months.

**Inputs**

* `value`: The value or column to rank.
* `[series]`: An optional series to rank the value against. Create the series using the `ARRAY` function.

**Examples**

1. `RANK(Oct 2026 Value)` ranks the October values within their own column. The customer with the highest October value receives rank `1`.
2. In the image below, the **October sales rank** calculation uses `RANK(Oct 2026 Value, ARRAY(Aug 2026 Value, Sept 2026 Value))` to rank October sales against August and September sales for each customer. The comparison is within each row, rather than between customers.

   In row 1, October sales of `89,560.44` rank `2`, below September but above August. In row 2, October ranks `1`, the highest of the three months. In row 9, October ranks `3`, the lowest.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FfwKQtXHRmE6f5mqKpbls%2Frank-october-sales.png?alt=media" alt="October sales rank compares October sales with August and September for each customer. Rows 1, 2, and 9 rank 2, 1, and 3."><figcaption><p><em>Read the results in the <strong>October sales rank</strong> column under <strong>Oct 2026</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>

### ROUND

`ROUND(value, places)`

Rounds a number to a specified number of decimal places.

Use `ROUND` to control the precision of values used in further calculations.

**Inputs**

* `value`: The value or column to round.
* `places`: The number of decimal places to round to. Use 0 for whole numbers, a positive number for decimal places, or a negative number for tens, hundreds, and so on.

Use `ROUND` when other calculations should use a rounded value. Use **Number format** in the column menu when you only want to change how values are displayed. Changing the number format leaves the value used in calculations unchanged.

**Examples**

1. `ROUND(2.558, 1)` returns `2.6`.
2. `ROUND(1234, -3)` returns `1000`.
3. In the image below, the **Rounded value** calculation uses `ROUND(Value, 0)` to round each value to a whole number.

   In row 1, `245,865.91` becomes `245,866`. It displays as `245,866.00` because the column's number format shows two decimal places.

   <div align="left"><figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FA8Ae20iaCW3fnoXn5Ia5%2Frounded-value-example.png?alt=media" alt="ROUND(Value, 0) rounds each value to a whole number. Row 1 displays 245,866.00 because the number format shows two decimal places." width="563"><figcaption></figcaption></figure></div>

   To hide the decimal places, open the **Rounded value** column menu and select **Number format**, then choose a format with no decimal places. In the image below, selecting **1235** displays the first result as `245866`, without a thousands separator. This changes the display only.

   <div align="left"><figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2F3p1o2Kg9yNcl7GbuHOQA%2Frounded-value-number-format.png?alt=media" alt="Choose the 1235 number format from the Rounded value column menu to display whole numbers without decimal places or thousands separators." width="563"><figcaption></figcaption></figure></div>

### SQRT

`SQRT(value)`

Returns the positive square root of a positive number.

Use `SQRT` when a calculation requires a square root. For example, calculate the side length of a square from its area: an area of 25 square meters gives a side length of 5 meters.

**Input**

`value`: The number or column for which to calculate the square root.

**Examples**

1. `SQRT(4)` returns `2`, because `2 × 2 = 4`.
2. In the image below, the **SQRT** calculation uses `SQRT(Sep 2026 4)` to calculate the square root of each value in the calculation column named **4**. Every row contains `4.00`, so every result is `2.00`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2Fq7QGk2WnFZikWzMU88XZ%2Fsqrt-column-example.png?alt=media" alt="SQRT uses the Sep 2026 calculation column named 4. Every row contains 4.00 and returns 2.00."><figcaption></figcaption></figure>

### SUM

`SUM(value1, [value2…])`

Adds numbers, columns, or column ranges. When you reference multiple columns, it adds the values in each row.

Use `SUM` to combine values from selected columns, such as calculating a customer's total sales or transaction count across several months.

**Inputs**

* `value1`: The first number, column, or column range to include in the sum.
* `[value2…]`: Optional additional numbers, columns, or column ranges to include in the sum.

**Examples**

1. `SUM(1, 2, 3)` returns `6`.
2. In the image below, the **SUM** calculation uses `SUM(Jun 2026 Count, Jul 2026 Count, Aug 2026 Count)` to add the three monthly **Count** values for each customer. Select each month's **Count** column header to include it in the formula.

   In row 1, the monthly counts are `5`, `5`, and `5`, giving a total of `15`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2Ft071GtSMGgKf2NKEIgFd%2Fsum-monthly-counts.png?alt=media" alt="SUM adds June, July, and August 2026 Count values in each row. Read the SUM results under Jun 2026."><figcaption><p><em>Read the results in the <strong>SUM</strong> column under <strong>Jun 2026</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>
3. In the image below, the **Sum Aug and Oct** calculation uses `SUM(Aug 2026 Value, Oct 2026 Value)` to combine sales for two selected months. September's value is excluded because its column is not included in the formula.

   In row 1, August sales of `39,594.81` plus October sales of `93,147.65` give a total of `132,742.46`.

   <figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FRCyfwE15Nb0G7m3ahGD2%2Fsum-aug-and-oct.png?alt=media" alt="Sum Aug and Oct adds August and October sales for each customer, excluding September. Row 1 returns 132,742.46 under Aug 2026."><figcaption><p><em>Read the results in the <strong>Sum Aug and Oct</strong> column under <strong>Aug 2026</strong>. The other repeated calculation columns show <code>#ERR</code>.</em></p></figcaption></figure>

### WORKINGDAYS

`WORKINGDAYS(id, columns)`

Returns the number of working days in a column's period or period range, as defined by the selected working days calendar.

Use `WORKINGDAYS` to calculate values per working day, such as average daily sales, using the calendar relevant to your business.

You need to [set up working day calendars](https://docs.phocassoftware.com/administration/periods-administration/working-days.md) to use this function.

**Inputs**

* `id`: The working days calendar to use. Select it from the list of available calendars.
* `columns`: The column or column range that supplies the period. Select a column associated with the period you want to count. Its measure and values do not affect the result. Leaving this input empty returns an error.

If you change the period associated with the selected column, the result updates to reflect the working days in the new period.

**Steps**

1. Select the `WORKINGDAYS` function to display the list of available calendars.
2. Select the calendar you want to use.

   <div align="left"><figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FtiT2cM1H18SrsHwKIAa2%2Fworkingdays-calendar-list.png?alt=media" alt="Select a working days calendar by name from the list, such as Working Days Excl Bank Holidays." width="563"><figcaption></figcaption></figure></div>
3. Select the column header associated with the required period.
4. Press **Enter** to apply the calculation.

{% hint style="success" %}
Type `wd` as a shortcut to find the function.
{% endhint %}

**Example**

In the image below, the **Working days excl hols** calculation uses `WORKINGDAYS(Working Days Excl Bank Holidays, Aug 2026 Value)`. The first input selects the calendar named **Working Days Excl Bank Holidays**. The second input selects the **Value** column for **Aug 2026**.

In this example, the selected calendar defines `21` working days in August 2026, `22` in September, and `22` in October. Each repeated calculation uses its month's period. Every row within a month returns the same result because the sales values do not affect the working day count. Results depend on how the selected calendar is set up.

<figure><img src="https://2122657374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGOWDU4SqRSiSPGXHgW%2Fuploads%2FOlwXZP4ZsfWcXQA3mm8Q%2Fworkingdays-monthly-example.png?alt=media" alt="The selected working days calendar returns 21 working days for August 2026 and 22 for September and October."><figcaption></figcaption></figure>

To count all days in a period, including weekends, see [DAYS](https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md#days).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.phocassoftware.com/analytics/customize-the-grid/manage-columns/use-functions-in-calculations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
