Skip to content

Formula reference

The formula of a calculated attribute is a single expression that produces one value. PIM evaluates it separately for every item that uses the attribute and for every segmentation, so the same formula can produce a different result per combination of market, channel, and language.

CONCAT(@BRAND, " ", @NAME)

Spaces, tabs, and line breaks between the parts of a formula are ignored. Other whitespace characters, such as a non-breaking space copied from a document, are not accepted.

Attribute references

A formula refers to another attribute by writing its system name with an @ in front.

Form Refers to Example
@NAME The default field of the attribute NAME @PRICE * 1.25
@NAME.FIELD The field with the system name FIELD on the attribute NAME @DIMENSIONS.WIDTH * @DIMENSIONS.HEIGHT
@NAME!, @NAME.FIELD! The same field, but without segmentation fallback ISEMPTY(@DESCRIPTION!)

A reference is case-insensitive, so @price and @PRICE refer to the same attribute. Attribute and field names consist of the letters A to Z, digits, and underscores, cannot start with a digit, and cannot be TRUE, FALSE, or NULL.

A plain reference resolves to the value that fits the segmentation being calculated: an exact match if one exists, otherwise the value for the country-neutral culture, otherwise the field's default value. Adding ! turns off that fallback, so only a value stored for exactly that segmentation is used, and the reference is NULL if there is none.

Only single-valued attributes can be referenced. Referring to a multi-valued attribute, to an attribute that belongs to an attribute value group, or to a name that does not exist, makes the formula fail.

Values

Kind Written as Notes
Number 42, 3.14, .5 The decimal separator is always .. Thousands separators and exponent notation are not supported.
Text "Autumn 2026" Double quotes only. Unicode characters such as æøå and emoji are supported. The following need escaping: \" for a quote, \\ for a backslash, and \n, \r, and \t for line breaks and tabs.
Boolean TRUE, FALSE Case-insensitive.
No value NULL Case-insensitive.

Operators

Operators are listed from the strongest binding to the weakest. Operators on the same row are evaluated from left to right, except ^, which is evaluated from right to left, so 2 ^ 3 ^ 2 is 2 ^ 9.

Operator What it does Example
( ) Groups a part of the formula (@PRICE + @FEE) * 1.25
- Negates the number that follows -@DISCOUNT
^ Raises to a power @SIDE ^ 2
* / % Multiplies, divides, and takes the remainder @PRICE / 2
+ - Adds and subtracts @PRICE - @DISCOUNT
> < >= <= == Compares two values @STOCK > 0

All arithmetic operators require numbers on both sides. + does not join text, so use CONCAT for that. The two sides of a comparison must be of the same kind, and text is compared alphabetically and case-sensitively, so "a" and "A" are not equal. There is no operator for "not equal to": write NOT(@COLOR == "Red") instead.

Functions

Function names are case-insensitive. PIM never converts a value on your behalf, so each argument must already have the kind the function expects. Use TEXT and NUMBER to convert.

Function What it does
CONCAT(text1, text2, ...) Joins two to ten texts into one.
LEN(text) Returns the number of characters in the text, and 0 when there is none. Emoji, and letters written as a base letter followed by a separate accent, count as two.
TEXT(number), TEXT(number, format) Converts a number to text. format is a standard or custom .NET numeric format string, for example "F2" for two decimals or "N2" for two decimals with thousands separators. The formula fails if the format string is not valid.
NUMBER(text), NUMBER(boolean) Converts text to a number, and fails if the text does not read as one. TRUE becomes 1 and FALSE becomes 0.
ISEMPTY(reference) Returns TRUE when the referenced field holds no value, or only whitespace.
AND(a, b), OR(a, b), XOR(a, b) Combines exactly two Boolean values. Nest the calls to combine more, as in AND(a, AND(b, c)).
NOT(a) Reverses a Boolean value.
BLANKASFALSE(a) Returns FALSE when the Boolean value is missing, and the value itself otherwise.

ISEMPTY is the way to check whether an attribute has a value. It works on fields of every kind, and it is the only function that takes a reference rather than a computed value. It resolves the reference the same way the rest of the formula does: ISEMPTY(@DESCRIPTION) uses segmentation fallback, and ISEMPTY(@DESCRIPTION!) looks only at the value stored for exactly the current segmentation.

Missing values

A reference to an attribute that has no value evaluates to NULL. NULL cannot take part in arithmetic or in a comparison, and a formula that tries to do so fails rather than returning an empty result. Guard the formula with ISEMPTY or BLANKASFALSE where a value may be missing.

Result type

Every calculated attribute has an expected result type, which is set when the attribute is created and cannot be changed afterwards. The formula must produce a value of that type:

Expected result type Accepted result
Decimal A number.
Boolean TRUE or FALSE.
String Any value. A number or a Boolean is converted to text.

A formula that produces a value of another kind, such as text when the expected result type is Decimal, has no result.

Errors

Errors in the formula itself are caught when the attribute is saved. The formula is refused with the message The formula is invalid at "X": Y, where X is the part of the formula that is wrong. This applies to a formula that cannot be read, such as one with a missing parenthesis, and to a call to a function that does not exist, which gives Unknown function X. as the reason.

Errors that depend on each item's data only show up when the formula is evaluated. The item then has no result. The most common ones of these are:

Message Cause
Attribute X not found. The formula refers to a system name that no attribute has.
Attribute Y has no field with system name X. The attribute has no field with that system name.
Attribute X is multi-valued. Multi-valued attributes cannot be referenced.
Attribute X is part of an attribute value group. Attributes in an attribute value group cannot be referenced.
Function X has no overload accepting (...). The arguments do not have the kinds the function expects.
Expression X, which evaluates to Y is not compatible with Z. An operator was given a value of the wrong kind, such as text where a number is required.
Cannot compare X to Y The two sides of a comparison are of different kinds.
X evaluates to 0. It's not possible to divide by 0. The formula divides, or takes a remainder, by zero.
The value is too long. A number in the formula, or the result, is larger than PIM can hold.

Formatting

The format action on the formula editor rewrites the formula in its canonical shape without changing what it does. Attribute, field, and function names become uppercase, true, false, and null become lowercase, and spacing around operators and between arguments is normalized.

Examples

Formula Result
@PRICE * 1.25 The price including 25 percent VAT.
CONCAT(@BRAND, " ", @NAME, " - ", @SERIES) A meta title assembled from three attributes.
CONCAT(@NAME, " (", TEXT(@WEIGHT, "N2"), " kg)") A label that mixes text and a formatted number.
AND(NOT(ISEMPTY(@DESCRIPTION)), LEN(@DESCRIPTION) > 120) Whether the description exists and is long enough.
BLANKASFALSE(@IS_ONLINE) The online flag, counting a missing value as FALSE.