Skip to content

Calculated attributes

A calculated attribute is special type of attribute in Bizzkit PIM. Its literal value is a formula that is used to calculate a result, for example based on other attribute values.

The configuration of a calculated attribute always contains one field of type PString, which by default has a System name of FORMULA. This field contains the formula or calculation of the attribute.

The System name _RESULT is reserved on calculated attributes and cannot be used for this field. It is set aside for the evaluated result of the formula.

In addition to the field configuration, the formula and expected result type of the formula are set as well. This expected result type can be one of the following:

Expected Result Type Description
Boolean Either TRUE or FALSE, often used to check conditions based on another attribute's value.
Decimal A numeric result, often used as result of actual calculations, such as price-related data.
String A text output of the formula, for example, when multiple attribute values are combined into a single text.

Field and calculation sections on configuration page for a calculated attribute

Field and calculation sections on configuration page for a calculated attribute
Calculated attributes are a bit like formulas in Excel

Excel also uses the concept of formulas, but it operates on cells instead of attributes, and worksheets or books instead of products (or other entities).

Excel formula

Here we have cell A:1 with the value My name, and another cell A:2 with a formula =LEN(A1) and the result 7, which is the length of the string value in A:1.

Purpose

Calculated attributes allow users to create dynamic attributes. They provide an extra layer of flexibility to the PIM attribute system by providing a way to calculate attribute values.

Examples of using calculated attributes in practice

  • Metadata: concatenate various string attributes like NAME, SERIES, etc. into a single field that can be used as meta title, meta description, etc. in a webshop
  • Price incl. VAT: add VAT on top of PRICE
  • Enrichment quality: make a simple enrichment quality assessment based on the length of various fields like for example DESCRIPTION

Usage

Calculated attributes can be used on all entities with an attribute collection, including products and product categories.

When using a calculated attribute, the formula as configured on the attribute configuration is used by default. This default formula can be overridden though, which allows for more specific overrides, for example on individual products.

Overriding the default formula for a calculated attribute

Overriding the default formula for a calculated attribute

Writing the formula

A formula is a single expression that produces one value, and it refers to another attribute by prefixing that attribute's system name with @. For example, @PRICE * 1.25 is the price plus 25 percent VAT.

The formula reference describes the full syntax: the values a formula can hold, the forms an attribute reference can take, the operators and functions that are available, and the errors a formula can produce.