Calculated Attributes

This page guides you through setting up calculated attributes, allowing you to automate the generation of content from formulas.

📘

Guidance

To get support in setting up this feature, please contact your integration partner.

Overview

Calculated attributes are dynamically generated from a formula. They can be used on product sheets.

A calculated attribute:

  • Is identified by a sigma symbol Σ,
  • Is non-localized and non-editable,


Setting Up a Calculated Attribute

Calculated attributes can be accessed from the Attributes page in the Administration menu.


To create a calculated attribute, select a document object type and a document type:

  • Click the lowest level of the hierarchy where you want to create the new attribute,

  • Click the Add an attribute button,

  • Fill in the following information:

    • Name (non-localized)
    • Code
  • Select the Calculated type.




Entering a Formula

The result of a calculated attribute is based on the formula defined in the Formula field.

In a formula, attributes are called by their code.

A formula consists of:

  • the codes of its source attributes,

  • mathematical operators (+, -, *, /),

  • functions:

    • roundup() -> Round away from 0,
    • rounddown() -> Round towards 0,
    • ceiling() -> Round to the highest value,
    • average() -> average,
    • concat() -> concatenation,
    • condition ? value if true : value if false.

📘

Good to know

  • For this first version: the result of a calculated attribute is always text type.
  • In a formula, an attribute code is always wrapped in two consecutive colons ::

🚧

Limitations

The formula cannot include:

  • another calculated attribute. If needed, copy the full formula from that attribute instead of using its code.
  • a localized attribute,
  • an html or json attribute,

❗️

Error Handling

  • If the formula is invalid, creation is blocked and an error message is displayed.
  • If a source attribute is empty or invalid (e.g., division by zero), an error appears on the product page with the cause specified.

Examples of Calculated Attribute Formulas

  • Text concatenation:

Goal: concatenate the text values of attributes, separated by a space.

Attribute CodeValue
attr_code_AHello
attr_code_BWorld
attr_code_CQuable

Formula: concat(::attr_code_A::," ",::attr_code_B::," ",::attr_code_C::)

Result: Hello World Quable

  • Average of values:

Goal: calculate the average of attribute values.

Attribute CodeValue
attr_code_A3
attr_code_B4.14
attr_code_C1

Formula: average(::attr_code_A::,::attr_code_B::,::attr_code_C::)

Result: 2.713

  • Sum of values:

Goal: calculate the sum of attribute values.

Attribute CodeValue
attr_code_A3
attr_code_B4.14
attr_code_C1

Formula: ::attr_code::_A::+::attr_code_B::+::attr_code_C::

Result: 8.14

  • Conditions:

Goal: If the attribute is <0, display A. If the attribute is <2, display B. If the attribute is <10, display C. If the attribute is <18, display D. Otherwise, display E.

Attribute CodeValue
attr_code_A3

Formula: ::attr_code_A:: < 0 ? "A" : ( ::attr_code_A:: <= 2 ? "B" : ( ::attr_code_A:: <= 10 ? "C" : (::attr_code_A:: <= 18 ? "D" : "E" ) ) )

Result: C


Automatic Calculation

A calculated attribute is updated when:

  • One of the formula’s source values is modified,
  • The formula itself is modified,

🚧

Limitations

  • All attributes used in the formula must be populated for the calculation to succeed.
  • A calculated attribute cannot be imported into a data model, nor updated via the API. Formula creation and editing must be done via the front-end interface only.
  • A calculated attribute cannot be made mandatory or enriched directly from a product sheet.
  • It is not possible to delete an attribute that is used in one or more formulas. You must first manually remove it from all relevant formulas.

Apply the Settings

Once all settings are configured, click the “Add” button to save all changes.



Best Practices

  • Document your formulas in the help field to facilitate maintenance, making it visible via the help text.

  • Result on the product sheet: