Exago Logo
Search
Generic filters
Exact matches only

Custom Aggregate Function: ArgumentMin()

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

Description Returns the corresponding correspondingValue associated with the minimum value of minimizedValue.
Arguments
  • minimizedValue: the field to find the minimum value of. Required.
  • correspondingValue: the corresponding value to return. Required.
  • recordLevel: indicates whether to aggregate by recordLevel (true) or entity level (false). Optional, defaults to true if not provided.
Namespaces
  • WebReports.Api.Common
  • WebReports.Api.Custom
Example To return the last name of the employee who has the least amount of revenue: ArgumentMin({OrderDetails.Revenue}, {Employees.LastName})

Program Code

public class MinMapAggregator: ICustomAggregator
{
 IComparable min;
 object minKey;

 public void AddValue(SessionInfo sessionInfo, object value, params object[] args)
 {
  // Treat nulls as zero
  if (value == null)
   value = 0;
  else if (!(value is IComparable))
  {
   throw new WrAggregationException(@"Tried to take the minimum of a set 
                                                      containing a non-comparable value");
  }

  if (this.min == null || this.min.CompareTo(value) == 1)
  {
   this.min = (IComparable)value;
   // The "key" to associate with the minimum value is passed as the second
   // argument to this aggregate function, which shows up here as the first item
   // in the args array.
   this.minKey = args[0];
  }
 }

 public object Result(SessionInfo sessionInfo)
 {
  return this.minKey;
 }
}
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