Used for: calculating how many elements a list has.
Used in: “THEN”-statements and “ELSE”-statements.
The "calculate list length” rule determines the number of elements in a list. This is particularly useful when you have all the available sizes of a product in a list and need to calculate the total number of sizes available.
For instance, if you have a list of sizes for a product, you can use this rule to determine how many sizes are available. The example rule in the screenshot below illustrates how this works for a specific product:
In the screenshot below, you can see how this rule would work for a specific product:
Calculate List Length (Unique Elements)
This is an extension of the “calculate list length” rule. It allows the user to count only unique elements in a list. This can be useful for ensuring that duplicate sizes are not counted multiple times.
For instance, if you have a list of sizes for a product, you can use this extension of the rule to determine how many unique sizes are available. In the screenshot below, you can see how this rule would work for a specific product:
In the screenshot below, you can see how counting only unique values in a rule works for a specific product: