# Formula functions reference

## Introduction

Pricing formulas can contain functions to make your product’s pricing even more powerful. Function parameters can be simple data (such as a number or text), or can contain dynamic code and variables like `[field.xxx]`

to reference dynamic data.

## All functions

### Available in all versions of the plugin

Function | Description | Example |
---|---|---|

`min(a; [b; c; ...])` | Returns the smallest of the given numbers. | min(100; [field.600d34143bd65]) |

`max(a; [b; c; ...])` | Returns the largest of the given numbers. | max(100; [field.600d34143bd65]) |

`len(string)` | Returns the length of a string. | len(a quick brown fox) |

### Available in the Extended version

Function | Description | Example |

`if(logical; value1; value2)` | Returns value1 if the logical argument is true, otherwise it returns value2. Can also be used to make nested IF statements. | if([field.600d34143bd65] > 50; 10; 20) |

`or(logical1; [logical2; ...])` | Returns true if any one of the arguments is true. | or([field.600d34143bd65];[field.799e14133be99]) |

`and(logical1; [logical2; ...])` | Returns true if all the arguments are true, returns false otherwise. | and([field.600d34143bd65];[field.799e14133be99]) |

`datediff(date1; date2)` | Returns the difference (in days) between two dates. | datediff([field.600d34143bd65];[field.799e14133be99]) |

`today()` | Returns today’s date. Can be used in the datediff function for further calculation. | today() |

`checked(field ID)` | Returns how many items are selected in a multi-select field (such as checkboxes, image swatches, …). | checked(600d34143bd65) |

`files(field ID)` | Returns the count of uploaded files for that field. | files(600d34143bd65) |

`round(number;decimals)` | Round (up or down) the value to the nearest number. You can optionally specify the number of decimals to round to. | round(4.8) => 5 round(0.33337; 4) => 0.3334 |

`ceil(number)` | Round up to the nearest number. | ceil(4.8) => 5 |

`floor` | Round down to the nearest number. | floor(4.8) => 4 |

`abs(number)` | Returns the absolute value of a number. | abs(-5) => 5 |

`pow(base; exponent)` | function returns the base to the exponent power, as in base^{exponent}. | pow(4;2) => 4² => 16 |

`sqrt(number)` | Returns the square root of a number. | sqrt(144) => 12 |

`sin(number)` | Returns the sine of a number. | sin(5) |

`cos(number)` | Returns the cosine of the specified angle. The number parameter specifies radians. | cos(5) |

`tan(number)` | Returns the tangent of a number. | tan(5) |

`sumQty(field ID)` | Sums all quantities entered by a user in a field that has several “quantity” inputs. Currently that is only applicable for the “images + quantities” field type. | sumQty(600d34143bd65) |

## Nesting functions

Nesting functions inside other functions is possible too. For example, you could create a more complex IF-ELSE structure like this:

`if( condition; true; if(condition2; true2; false2))`

Just like with Excel functions, you can use the `and()`

and `or()`

function inside the `if`

function. Let’s say you want to do something when X = 1 or X = 2, then you would write your function like this:

`if( or(x=1; x=2); then; else )`

## Troubleshooting formulas

Are you using functions but your formulas produce incorrect results? Check this article to troubleshoot your formulas.