Using Operators
Formulas can consist of references and constants separated by operators. The value of a formula is calculated from left to right; they are left associative.
Operators are used with references and Axel-f functions. Here is a very simple illustration of the use of operators ( + ) with references.
1
modelbyid.base_price + enginebyid.body.price + dealer.body.discount
Copied!
Operations are grouped from the left. Any field expression can be used as an operand for an operator.
MAP(FN(x, ROUND(x * 1.1, 2)), allvariants.body.[].base_price_EUR)
When more than one operator occurs in an expression, it is evaluated based on order precedence. In general, arithmetic operators are evaluated first followed by comparison operators. To change a precedence of operators, enclose in parenthesis the part of the formula to be calculated first.
  • ((2+2)*2 => 8)
Operator types valid in Xapix include:
  • .(dot) operators
  • Array operators
  • Arithmetic operators
  • Concatenation operators
  • Comparison operators
  • Logical operators

Example

Suppose we create an endpoint parameter called total_price. For this parameter, two references and an operator are used to resolve to the value we want:
  • findvariantbyid.body.base_price_EUR
  • findenginebyid.body.price
We first create an endpoint parameter called total_price. In the Endpoint unit, expand body, then click New Property.
In the New Property field, enter total_price, click Literal and then Create.
Expand total_price, then in the dark green area click Set Formula to open the Formula editor.
In the Formula editor, enter the following, then click Save:
1
findvariantbyid.body.base_price_EUR + findenginebyid.body.price
Copied!
If you have entered the formula correctly, a Formula valid message appears. Click Save.
The resolved value appears under the endpoint parameter name, total_price.

Array operators

Operator
Syntax
Description
Example
:
operand1:operand2
Represents a range of values.
1:5 evaluates to [1,2,3,4]
,
{value1, value2}
Divides elements in an array. Single spaces are ignored.
{1, 2, 3} evaluates to [1,2,3]

Arithmetic operators

Operator
Syntax
Description
*
operand1 * operand2
Multiply two operands.
/
operand 1 / operand2
Divide two operands.
+
operand1 + operand2
Sum or add two operands.
-
operant1 - operand2
Subtract right operand from left operand.
^
operand^exponent
Raise operand to the power of the exponent.

Concatenation operators

Operator
Syntax
Description
&
operand1 & operand2
Appends (concatenates) two operands or strings together.
See CONCATENATE. This function is not to be confused with CONCAT, which appends two arrays.

Comparison operators

Operator
Syntax
Description
>
operand1>operand2
Left operand is greater than right operand. Evaluates to true or false.
<
operand1<operand2
Left operand is less than right operand. Evaluates to true or false.
>=
operand1>=operand2
Left operand is less than or equal to right operand. Evaluates to true or false.
<=
operand1<=operand2
Left operand is less than or equal to right operand. Evaluates to true or false.
=
operand1=operand2
Left operand is equal to right operand. Evaluates to true or false.
<>
operand1<>operand2
Left operand is not equal to right operand. Evaluates to true or false.
%
operand1%operand2
Remainder operator that evaluates the remainder after dividing left operand by right operand.

Logical operators

Operator
Syntax
Description
Example
!
!operand1
computes a logical negation on an operand or expression.
!24