graham

Counting Records

Blog Post created by graham on Oct 12, 2018

I wanted to be able to do a Group Count on a set of items in a library (I actually wanted to save the values and counts to a list so that I could attach a chart control – but that’s another story).

There is no way of doing a Group By in the Query List task, so I had to come up with this.

Retrieve all my key values into a collection, then create a list of those unique key values

Iterate through the unique values and remove them from the original list – the number of items matching the key value is the number of items removed from the collection – the difference between the counts before and after the deletion.

In pseudocode, the process is this

QueryList : get all ‘key values’ in range into collection AllKeys

Collection: Remove duplicates from AllKeys into collection UniqueKeys

ForEach string Key in UniqueKeys

Collection: Count AllKeys into number Total

Collection: Remove by value Key from AllKeys

Collection: Count AllKeys into number Count

Math: Total Count into number KeyCount

{do something with Key and KeyCount}

EndLoop

Outcomes