# How to use Formulas in your RowShare tables?

RowShare calculated columns are formulas based on the value of the other cells of the same row. Add a "Calculated value" column and specify the formula in this column’s settings. Yes, this means that the formula will always be the same in a given column.

Start by adding a new column to your table, and click "Automatic" and “Calculated Value”. Give a name to your column, and scroll to the bottom to enter the formula:

Calculated values can include 4 types of content:

#### References to other columns

A column is referenced by its name, surrounded by squared brackets [ ]. Examples:

- [Name]
- [Customer Name]
- [Price]

#### Constant values

These values are typically numbers or text. Text must be surrounded by double quotes. Examples:

- 1
- 878
- "Dr"

#### Operators

- 4 standard mathematic operations: +, -, *, /
- Comparison operators: >, <, >=, <=, =, !=, <> (the last two ones are equivalent and mean "not-equal")

#### Functions

RowShare offers additional functions to manipulate numbers, text, dates and introduce logical operations.

##### Numbers

- Rand() : returns a random numeric value between 0 and 1
- Abs(number) : returns 1 for positive numbers and -1 for negative numbers
- Floor(number) : Returns the largest integral value less than or equal to the specified number
- Ceiling(number) : Returns the smallest integral value greater than or equal to the specified number
- Round(number) : Rounds a number to the nearest integer number
- Truncate(number): returns the integral part of a number.

##### Time

- DateDiff(leftDate, rightDate) : returns the number of days between 2 dates
- Now() : returns the current date and hour, based on the current user timezone as set in his account.
- Utcnow() : returns the current UTC date and hour.

The following functions take a date as parameter and return the corresponding year/month/day/hour...

- Year(date)
- Quarter(date)
- Month(date)
- WeekOfYear(date)
- Day(date)
- DayOfWeek(date)
- Hour(date)
- Minute(date)
- Second(date)
- Millisecond(date)

##### String

- lower(string) : converts a string to lowercase
- upper(string) : converts a string to uppercase

##### Logic

**IF(condition, ifTrue, ifFalse)**takes 3 parameters: 1st is the condition, 2nd is the result if the condition is met, the 3rd is the result otherwise.

`IF(COL1 > 0, 1 , -1)`

. You could also have used Abs(COL1) to get the same result.**ISNULL(left, right)**takes 2 parameters: if the first one is NULL (empty cell), it will return the second parameter. If the first one is not null, it will be returned.

`ISNULL([First Name],"") + " " + [Last Name]`

#### Examples

· **Numbers: **To calculate the sum of two columns *Total Price*and *VAT*, the formula is: `= [Total Price] + [VAT]`

· **Text: **To combine the columns *First Name* and *Last name*together, the formula is: `[First name] + [Last name]`

Of course, it would look better with a space between first name and last name. Add it between double quotes: `[First name] + " " + [Last name]`

### Important Notes

- In any calculation, if you include an empty cell, the formula will not function properly and will return an empty cell. To avoid this, use
`ISNULL()`

. - Calculated values can not reference other calculated values.
- Calculated values do not function if referenced column names include one of the following characters:
- .
- \
- [
- ]

- You can show calculated field as percentage: go to the column settings by clicking on the settings button on the header of that column, change your column type to “Advanced”, set the data type to “Number”, and you will find “Percentage” box, set it as “Yes”.