Title: TablePress features explained: Formulas
Author: Tobias Bäthge
Published: November 27, 2013
Last modified: March 19, 2025

---

[Features](https://tablepress.org/category/features/)

·

November 27, 2013

# TablePress features explained: Formulas

TablePress supports mathematical functions and formulas in table cells, in a very
similar way as they can be used in Excel or other spreadsheet applications. Almost
all Excel formulas are supported — just make sure to use their English name!

The following table shows some examples of made-up data and formulas that calculate
something:

  |   | A | B | C | D |  
   |  1 | Data 1: | Data 2: | **Formulas:** | **Result:** |  
 |  2 | 1 | 0.4 | =A2+A3+A4 | 8 |  
 |  3 | 2 | -0.9 | =Sum: {SUM(B2:B8)} | Sum: 11.5 |  
 |  4 | 5 | 4.5 | =SIN(PI()/2) | 1 |  
 |  5 | 4 | -0.1 | =ABS(B3)+CEIL(B4,0) | 0.9 |  
 |  6 | 3 | 2.2 | =POWER(A4,A5) | 625 |  
 |  7 | 7 | -0.4 | =MEDIAN(A2:A8) | 4 |  
 |  8 | 8 | 5.8 | =IF(A4>A5,1,0) | 1 |

The content of a cell is evaluated as a formula, if it starts with the equal sign`
=`.
Formulas can reference other cells, by stating the column letter and the row
number. It is possible to use single references, like `A2`, or to reference multiple
cells in a row, column, or even block, by using the colon (`:`) operator. With that,`
A2:A8` means all cells in the `A` column, while `A3:E3` would refer to all cells
in the third row.Those references will even be adjusted automatically whenever the
referenced cell changes position in the table, e.g. because its row or column is
moved or because another row or column is deleted or inserted.

Also, it is possible to wrap a formula in text, with the syntax `=TEXT{FORMULA}TEXT`.
The cell content still has to start with the equal sign `=` and the formulas then
have to be wrapped in curly brackets `{`and `}`. This can be seen in the example`
=Sum: {SUM(B2:B8)}` in cell C3 in the table above.

Most of the supported functions expect only one argument, either a number, or a 
reference to a cell, while some of the functions will work with multiple arguments,
either given as a comma-separated list, or by using the colon operator that is described
above.

These functions are supported by TablePress:

#### Math operators:

  |  `+` | addition |  
 |  `-` | subtraction |  
 |  `*` | multiplication |  
 |  `/` | division |  
 |  `^` | power |

#### Comparison operators:

  |  `=` | equal |  
 |  `<` | smaller than |  
 |  `>` | greater than |

#### Placeholder variables:

  |  `TABLE_ID` | ID of the current table |  
 |  `NUM_ROWS` | Number of rows of the current table |  
 |  `NUM_COLUMNS` | Number of columns of the current table |  
 |  `ROW` | Number of the row of this cell |  
 |  `COLUMN` | Number of the column of this cell |  
 |  `CELL` | Cell name/reference of this cell |

#### Basic math functions:

  |  `sqrt(_x_)` | Square root of _x_ |  
 |  `abs(_x_)` | Absolute value of _x_ |  
 |  `ln(_x_)` | Natural logarithm of _x_ (_Logarithm of x to the base e_) |  
 |  `log(_x_,_b_)` | Logarithm of _x_ to the base b |  
 |  `log10(_x_)` | Logarithm of _x_ to the base 10 |  
 |  `exp(_x_)` | Exponential function |  
 |  `power(_x_,_y_)` | Value of the _x_ raised to the _y_th power |  
 |  `round(_x_,_p_)` | Round _x_ to the precision _p_ (The default _p=0_ will result in an integer.) |  
 |  `floor(_x_)` | Greatest integer that is smaller or equal to _x_ |  
 |  `ceil(_x_)` | Smallest integer that is greater or equal to _x_ |  
 |  `pi()` | Value of π (3.14159…) |

#### Statistics functions:

  |  `average(_…_)`
 _(also as `mean(…)`)_ | Average value of the arguments |  
 |  `median(_…_)` | Median value of the arguments |  
 |  `mode(_…_)` | Mode value (most common value) of the arguments |  
 |  `range(_…_)` | Range: Difference between the largest and smallest arguments |  
 |  `max(_…_)` | Largest value of the arguments |  
 |  `min(_…_)` | Smallest value of the arguments |  
 |  `mod(_x_,_y_)` | Remainder of the division _x_ divided by _y_  |

#### Other functions:

  |  `number_format(_x_,_d_)` | Formats _x_ with _d_ decimals after the period _._ where the comma _,_ will be used as the thousands delimiter (if _x_ has more than four digits) |  
 |  `number_format_eu(_x_,_d_)` | Formats _x_ with _d_ decimals after the comma _,_ where the period _._ will be used as the thousands delimiter (if _x_ has more than four digits) |  
 |  `sum(_…_)` | Sum of the arguments |  
 |  `product(_…_)` | Product of the arguments |  
 |  `rand_int(_a_,_b_)` | Random integer between _a_ and _b_ |  
 |  `rand_float()` | Random real number between 0 and 1 |  
 |  `if(_condition_,_then_,_else_)` | If _condition_ is true, _then_ will be returned, and _else_ otherwise |  
 |  `counta(_…_)` | Number of non-empty values from the arguments |

#### Trigonometric functions:

  |  `sin(_x_)` | Sine of _x_ |  
 |  `sinh(_x_)` | Hyperbolic sine of _x_ |  
 |  `arcsin(_x_)`
 (_also as `asin(x)`_) | Inverse sine of _x_ |  
 |  `arcsinh(_x_)` (_also as `asinh(x)`_) | Inverse hyperbolic sine of _x_ |  
 |  `cos(_x_)` | Cosine of _x_ |  
 |  `cosh(_x_)` | Hyperbolic cosine of _x_ |  
 |  `arccos(_x_)` (_also as `acos(x)`_) | Inverse cosine of _x_ |  
 |  `arccosh(_x_)` (_also as `acosh(x)`_) | Inverse hyperbolic cosine of _x_ |  
 |  `tan(_x_)` | Tangent of _x_ |  
 |  `tanh(_x_)` | Hyperbolic tangent of _x_ |  
 |  `arctan(_x_)` | Inverse tangent of _x_ |  
 |  `arctan2(_x_,_y_)` (_also as `atan2(x,y)`_) | Inverse tangent of the quotient _x_/_y_, while taking the sign into account |  
 |  `arctanh(_x_)` | Inverse hyperbolic tangent of _x_ |

Note that all of them work with pure numbers only. If you need to do calculations
on e.g. dates or work with text, you should consider using Excel or similar and 
export the final results table as a CSV file and import that into TablePress.