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.
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. |
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).
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.
Reference
The following references show the different functions and operators that are available when working with calculated attributes.
Functions
Function | Description | Example |
---|---|---|
CONCAT(value1 , value2 , ... ) |
Combines multiple values to a single text value by concatenating the provided values. | CONCAT("Hello", " ", "World") results in "Hello World" |
ISNULL(value ) |
Determines if the provided value is NULL |
ISNULL(NULL) results in TRUE |
ISBLANK(value ) |
Determines if the provided value is blank or empty |
ISBLANK("") results in TRUE |
TEXT(value ) |
Converts a value to text format | TEXT(123) results in "123" |
NUMBER(value ) |
Converts a value to a number format | NUMBER("123") results in 123 |
OR(value1 , value2 ) |
Returns TRUE if any of the provided conditions are TRUE |
OR(TRUE, FALSE) results in TRUE |
AND(value1 , value2 ) |
Returns TRUE if all of the provided conditions are TRUE |
AND(TRUE, TRUE) results in TRUE |
XOR(value1 , value2 ) |
Returns TRUE if an odd number of the provided conditions are TRUE |
XOR(TRUE, FALSE) results in TRUE |
NOT(value ) |
Returns the opposite of the provided condition | NOT(TRUE) results in FALSE |
BLANKASFALSE(value ) |
Treats blank values as FALSE in logical operations |
BLANKASFALSE(ISBLANK("")) results in FALSE |
LEN(value ) |
Returns the length of the provided value |
LEN("Hello") results in 5 |
Operators
Operator | What It Does | Example |
---|---|---|
( | Starts a group of operations | (a + b) |
) | Ends a group of operations | (a + b) |
* | Multiplies two numbers | a * b |
/ | Divides one number by another | a / b |
% | Finds the remainder of division | a % b |
+ | Adds two numbers together | a + b |
- | Subtracts one number from another | a - b |
> | Checks if one number is greater | a > b |
< | Checks if one number is smaller | a < b |
<= | Checks if one number is smaller or equal | a <= b |
>= | Checks if one number is greater or equal | a >= b |
== | Checks if two numbers are equal | a == b |