Count Item Occurrences If

Verb: collectionCountIf

Counts items in a collection if the specified condition is met.

Collections are enumerable data structures that can be accessed using indexes and keys.


collectionCountIf --collection(List<Variant>) --operator(ConditionalOperators) --value(Variant) [--negate(Boolean)] (Numeric)=value


Script Designer Required AcceptedTypes Description
--collection Collection Required List<Any>, String Dictionary<Any> Collection of which the items should be evaluated and counted.
--operator Operator Required ConditionalOperators Rule used to evaluate the condition. Options:
  • Begins with
  • Contains
  • Ends with
  • Equal to
  • Greater than
  • Greater than or equal to
  • Is empty
  • Is null
  • Is null or empty
  • Is true
  • Less than
  • Less than or equal to
  • Matches
  • --value Value Only whenOperator is Equal_To, Greater_Than, Greater_Than_Equal_To, Less_Than, Less_Than_Equal_To, Contains, Ends_With, Begins_With, Matches Any Value used to evaluate each item in the collection according to Operator.
    --negate Negate Optional Boolean Negates the rule in Operator.


    Script Designer AcceptedTypes Description
    value Count Number Amount of items counted based on the condition.


    Counts items in the collection based on the condition defined with the Less than operator.

    defVar --name numbersCollection --type List --innertype Numeric --value "[1,2,3,4,5,6,7,8,9,10,11,12]"
    defVar --name quantityOfItems --type Numeric
    //Counts items smaller than 7.
    collectionCountIf --collection "${numbersCollection}" --operator "Less_Than" --value 7 quantityOfItems=value
    logMessage --message "${quantityOfItems}" --type "Info"
    // The result obtained in $ {quantityOfItems} is: 6.

    See Also

  • Copy List with Restrictions
  • Get Item Index
  • Insert Item into List
  • Remove from Collection If
  • Remove From List
  • Remove Value