We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

Countif Functionality in Data360



  • Avatar
    Adrian Williams

    The Aggregate node provides an aggregation function for counting values (as well as functions for sum, min, max, etc). The operations using the grid editor cover standard use cases such as generating a raw count or sum of values (by group if required).

    However, you will need to create a custom aggregate in the Advanced tab of the Operations property if you want to build operations equivalent to Countif.

    The ConfigureFields and ProcessRecords scripts that are automatically generated for the above configuration are displayed in the Advanced tab:

    The group.count() function is one of the supported aggregation functions that can be used by the Aggregate node. The available grouping functions are described in the Help documentation. The section for the group.count() function describes how you can include an optiopnal updatePredicate function to construct an aggregate that provides a conditional count of values that match the specified criteria.

    As stated in the Help documentation, the update Predicate must be a lambda function that returns a boolean True/False value. In the following example, the default ConfigureFields script generated from the Grid editor has been modified to include an updatePredicate lambda function:


    lambda agg, newValue: fn.cmp(newValue, "primary") == 0

    The fn.cmp() comparison is used to compare the value in the current record (newValue) with the string "primary". The result of this comparison is tested to determine if it is equal to 0 (i.e. the strings values match). If the values match, the result of the lambda function will be True and the aggregate value will be incremented

    The data flow for this example is attached below (requires Data360 Analyze 3.6.0 or above).



    Attached files

    Aggregate_Node Conditional_Count_example - 22 Oct 2020.lna


    Comment actions Permalink
  • Avatar
    Aditya Ayri

    Thank you so much for your help.
    This is useful.

    Comment actions Permalink

Please sign in to leave a comment.