> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.pricer24.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Formula-Based Competitor Pricing

# Formula-Based Competitor Pricing

Formula-based price types can be created and edited in the "Competitors" module. 
To do this, open the competitor editing dialog and navigate to the "Prices" tab.
All price values involved in the calculation are converted to the currency of the formula-based price.
The calculation result is rounded according to the currency settings of the formula-based price.


|| Formula-based prices are calculated at the moment of data load into the client's account. If the rules are changed, they will be applied on the next data load.

### **Formula Syntax**
Formulas are implemented using the [NCalc](https://ncalc.github.io/ncalc/index.html) library.
As variables, the codes of existing price types must be specified in square brackets (not of the "formula" type). Example: `[price]`, `[price_min]`

###### Functions
The list of built-in functions can be found at the [link](https://github.com/ncalc/ncalc/wiki/functions).
The following custom functions are also supported:
* `MinEx(arg1,arg2,...,argN)` - returns the minimum value from the list of N arguments passed
* `MaxEx(arg1,arg2,...,argN)` - returns the maximum value from the list of N arguments passed
* `AvgEx(arg1,arg2,...,argN)` - returns the average value from the list of N arguments passed
* `CoalesceEx(arg1,arg2,...,argN)` - returns the first non-NULL value from the list of N arguments passed

###### Operators
The list of built-in operators can be found at the [link](https://github.com/ncalc/ncalc/wiki/Operators).

###### Formula Examples

Example 1. Calculating a promo price
```
if([price_old] > 0, [price], null)
```

Example 2. Calculating the minimum of three prices
```
MinEx([price], [price_net], [price_old])
```
