Exago Logo
Generic filters
Exact matches only

Custom Aggregate Function: AggCountIf()

Review the documentation on Custom Aggregate Functions for full details on developing and implementing this function.

Description Returns the count of values of dataToAggregate with a corresponding true condition.  Only those records with a true condition are included in the count. condition is true if it meets any one of the following conditions:

  • it is the boolean type true
  • it is the string “true
  • it is the function True()
  • it is a non-zero number, or can be converted to a non-zero number
  • dataToAggregate: the data field to count, accepts data fields or cell references. Required.
  • condition: a boolean value or expression that when true will include this item in the count. Required.
  • recordLevel: indicates whether to aggregate by recordLevel (true) or entity level (false). Optional, defaults true if not provided.
  • WebReports.Api.Common
  • WebReports.Api.Custom
Example To return the number of current products: AggCountIf({Products.ProductName}, Not({Products.Discontinued}))

To return the number of orders whose revenue was greater than $15,000.00:
AggCountIf({Orders.OrderId}, if({OrderDetails.Revenue} > 15000))

Program Code

public class AggCountIf : ICustomAggregator
    int count = 0;
	public void AddValue(SessionInfo sessionInfo, object value, params object[] args)
        bool isTrue;
        double number;
        if ((bool.TryParse(args[0].ToString(), out isTrue) && isTrue) || 
            (double.TryParse(args[0].ToString(), out number) && number != 0))
	public object Result(SessionInfo sessionInfo)
		return this.count;
Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Table of Contents