Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: awilliams1024Hi Tris,
Just to clarify the original error condition: This error is not related to the fields in the GroupBy property, the error is being generated because the groupCount() function is expecting a Boolean data type attribute if there is a statement configured within the parentheses - i.e. in your scenario the first line in the Agg Ex node script is:
Cust_Combo_Count = groupCount('Cust_Transactions')
so the node expects 'Cust_Transactions' to be a Boolean field. Normally for a simple count of items within a sub-group of the data you do not need to specify an attribute so the statement would just be:
Cust_Combo_Count = groupCount()
This will count the number of records in the sub-group specified by a unique combination of the GroupBy fields. If you just wanted to count the total number of input records you could use
total_Records = groupCount()
and set the GroupBy property to true or 1 - which causes the Agg Ex node to treat all the records as belonging to a single group.
The alternate format for the groupCount() function with an argument is used when you want to conditionally count the number of occurrences within a sub-group. For instance, if I had some order data comprising the fields:
- SalesRegion # String: North/South/East/West
- SalesPersonID # String: 101/102,103, 104, ...
- OrderAmount # Double: 500.00, 2341.50, 4500.00, 9999.99, ...
If I wanted to count the number of orders by SalesRegion where the value of the OrderAmount was greater than or equal to 3,000 then I could configure the Agg Ex node as follows:
##SortInput property:
true
## Script property:
CountOrdersOver3K = groupCount(OrderAmount >= 3000)
emit referencedFields(1,{{^GroupBy^}}), CountOrdersOver3K
where lastInGroup
## GroupBy Property:
SalesRegion
The groupCount() predicate statement (OrderAmount >= 3000) will result in a Boolean value that determines whether the aggregate value is incremented for that record.
In your particular scenario you wanted the count of the occurrences of 'Customer Combo' so just using groupCount() as the aggregation method with a GroupBy of 'Customer Combo' should yield the required count values.
Regards,
Adrian