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[n] Field number n of the attribute NAME @DIMENSIONS[1] * @DIMENSIONS[2]
@NAME!, @NAME[n]! The same field, but without segmentation fallback ISBLANK(@DESCRIPTION!)

A reference is case-insensitive, so @price and @PRICE refer to the same attribute. 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.

Formulas written before the @ prefix

Earlier versions of PIM identified a reference by its system name alone, without a prefix. Formulas written then are shown with the prefix and stored with it the next time they are saved, and a formula saved without it is rejected. An unprefixed reference is still evaluated, but support for it will be removed.

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.
ISBLANK(reference) Returns TRUE when the referenced field holds no value, or only whitespace.
ISNULL(text) Returns TRUE when the text is missing.
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.

ISBLANK is the reliable way to check whether an attribute has a value, and it is the only function that takes a reference rather than a computed value. It always looks at the value stored for exactly the current segmentation, as @NAME! does. ISNULL only accepts text, so it cannot be used on a number or a Boolean field.

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 ISBLANK or BLANKASFALSE where a value may be missing.

Errors

A formula that cannot be evaluated produces an error instead of a value. The most common ones are:

Message Cause
Attribute X not found. The formula refers to a system name that no attribute has.
Field ordinal X for attribute Y is out of range. The attribute has no field with that number.
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.
Unknown function X. The function does not exist, or the name is misspelled.
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 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(ISBLANK(@DESCRIPTION)), LEN(@DESCRIPTION) > 120) Whether the description exists and is long enough.
BLANKASFALSE(@IS_ONLINE) The online flag, counting a missing value as FALSE.