Exago Logo
Search
Generic filters
Exact matches only

Custom Aggregate Function: AggConcat()

Review the documentation on Custom Aggregate Functions for full details on developing and implementing this function. This function must be implemented by a system administrator before it can be used in a report.

Description Returns a concatenated string of values separated by a specified delimiter string.
Arguments
  • dataToAggregate: the value to concatenate, accepts data fields or cell references. Required.
  • delimiter: the string to separate each value with. Optional, defaults to comma and a space if not provided.
  • 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 AggConcat({Categories.CategoryName}, ":")
Beverages:Condiments:Seafood
AggConcat({Categories.CategoryName})
Beverages, Condiments, Seafood

Program Code

public class AggJoin : ICustomAggregator
{
    System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
    string delimiter = ", ";
    
	public void AddValue(SessionInfo sessionInfo, object value, params object[] args)
	{
        // Skip blank values
	 if (value == null || value.ToString() == string.Empty)
            return;
        
        if (args.Length != 0)
        	this.delimiter = args[0].ToString();
        
        this.stringBuilder.Append(value);
        this.stringBuilder.Append(this.delimiter);
	}

	public object Result(SessionInfo sessionInfo)
	{
        string retVal = this.stringBuilder.ToString();
        
        // Remove the trailing delimiter
        if (this.delimiter.Length > 0 && retVal.Length > 0)
            retVal = retVal.Remove(retVal.Length - this.delimiter.Length);
        
        return retVal;
	}
}
Was this article helpful?
0.5 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 100%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Table of Contents