Count Sum Items in Collection
Description
The list_count part returns the count, sum, or iterated count of items in a single or multi-dimensional array.
Use
You can use this part to gain insight into the data held in a collection. When you choose the SUM mode, the part cycles through a simple collection of items (1...2....etc.) and presents the sum of those items when the item is numeric. When you choose COUNT or ITERATED COUNT, the system counts the number of items cycled through based on their index (count) or non-indexed (iterative count) nature.
When the count of items in a collection equals zero, this indicates the collection is empty. This can be a useful variable to incorporate into a rule that can be used in directing the pathway (if the collection is not empty, then process items in the collection, otherwise proceed down alternative path). Note that for indexed collections (collection[1].item, collection[2].item....) it is more efficient to just check whether the first item is empty (collection[1].item is not "")
Tips and Tricks
This part should only be used with collections (arrays). If you are working with groups/containers, then use the group calculations part to count items. (See the article here).
Using the DATA tab, you can identify whether your data model is using collections or groups/containers as follows:
Editor Fields
Field Name |
Description/Use |
Type/Options |
Optional/Mandatory |
Data object |
Object name where the returned value will be stored. |
Text |
Mandatory |
Collection |
Name of the collection containing the object items to be counted or summed up. |
Collection |
Mandatory |
Mode |
Selector allowing the choice of count or sum or iterated count. |
Dropdown |
Mandatory |
Value field |
This option only applies to SUM mode. Specify the particular (numeric) dimension in the array to calculate the sum of all values of that dimension. |
Text |
Optional |
Big number calculation |
Checking this box enables the part to sum across "big numbers" - those that cannot be represented in 32 bits. |
Checkbox |
Optional
|
Example
Download and import the following example project in your workspace. This example is the How to Guide for Collections and focuses on sum and count on one of the tabs.