# Functions in expressions

Functions allow you to perform mathematical operations on the values received from customer attributes or events. Many of those functions duplicate the functions that you can find in programs such as Excel.

## Abs

It returns the absolute value of the results of a customer attribute or event. In cases when you want to convert a negative number, you may use absolute value to obtain a positive number in an expression.

This function returns a date, ahead of the given date by the number of given years

USE CASE: Check whether customers reached the legal age of adulthood.

1. Add the `Add years` function that allows you to perform mathematical operations with regard to dates.

2. Then, place the `Now` function within the `Add years` function. In the next field, type in the number which you want to deduct from the current date (year), so you can verify if the customer is of legal age. In some countries, citizens who are 18 years old are considered adults, so in order to deduct 18 years from the current date, we entered `-18`. To complete the process, click the Save button.

3. Create a segment that consists of adult customers. Such segmentation needs to comprise of 2 steps. In the first step, use `birthdate` as the customer attribute and `Less than` as a logical operator. Then select the expression, which you created in previous steps, as the value of the `Less than` operator. In the second step, you need to select adult customers among those whose date of birth is available on the contact card. Use `birthdate` as the customer attribute in the second step. Then, determine its value as `true`. Between step 1 and 2 use `AND` as a logical operator.

## Ceil

Ceiling rounds up the results of expression (e.g. 4.01 will be rounded up to 5).

## Exp

Exponentiation returns the results raised to the power given in the brackets.

## Floor

This function rounds down the results of expressions (e.g. 4.99 will be rounded down to 4).

## IfNull

This function returns a boolean value (true or false) that indicates whether the expression contains any valid data (null) and returns `true` if it doesn’t.

## Ln

This function returns the natural logarithm of a given number.

## Max

This function returns the highest value in a set of values.

## Min

This function returns the lowest value in a set of values.

## Mod

This function returns the remainder after division of one number by another The result has the same sign as the divisor.

## Round

This function rounds the expression value to an integer number. According to mathematical principles, values from 01 do 49 are rounded down and values higher than 49 are rounded up.

## If

Allows logical comparisons between values. The system creates the desired structure automatically when you select this function.

1. After you choose the If function, the expression will be constructed in the specific pattern explained points 2-5.
2. The first field in the brackets is taken by the condition that needs to be met, if you want a specific action to happen (3). In this case, the condition consists of the segment of customers who made a purchase on the current day.
3. The next place is taken by the expression that is executed when the condition is met/is true (2). In this example, the expression `Last transaction` will be the subject of action. If the condition is true, the value of the last transaction will be multiplied by the number in the next field (4).
4. This place is taken by the value which will be considered if the condition (2) is true. In this example, the value of the last transaction in the current day will double.
5. This place is taken into consideration if the condition (2) is false. If the condition is false, the value of the expression will be equal 0.
Tip: You can extend the conditions, include analytics and add subsequent functions to expressions.

## Equals

It allows you to check if two values are equal. Returns `true` if they are.

## Greater

This function checks if the first given value is larger than the second one. Returns `true` if it is.

## Greater or equals

This function checks if the first given value is larger than or equal to the second one. Returns `true` if it is.

## Less

This function checks if the first given value is smaller than the second one. Returns `true` if it is.

## Less or equals

This function checks if the first given value is smaller than or equal to the second one. Returns `true` if it is.

## Not equals

This function allows you to check if two values are different. Returns `true` if they are.

## Now

This function allows you to insert the current date or time to your formula.

## To string

This function allows you to convert the result of an expression to a string.

## To number

This function allows you to convert the result of an expression to a numerical value.

## To timestamp

A timestamp is a sequence of characters or encoded information identifying when a certain event occurred. Because timestamps may take various formats, you can use this function to convert a date into a timestamp of a universal format (ISO) so later you can perform actions on dates. It is especially useful when you want to use a time dimension in reports.

## Concat

This function joins two or more strings together and returns the joint string as the result.

## Day of month

This function returns the day of the month.

Tip:

Use this function in event expressions. Later you can use them as a dimension in reports. Expression with the Day of month formula used as dimension in reports

## Day of week

This function returns the day of the week in the form of a number (values from 1 [Monday] to 7 [Sunday]).

Tip: Use this function in event expressions. Later you can use them as a dimension in reports.

## Day of year

This function returns the number of the day of the year (values from 1 to 366).