client/splunk.js
function(fieldName, label, statsFunction) {
            if (!this.dataModelObject.hasField(fieldName)) {
                throw new Error("Did not find field " + fieldName);
            }

            var f = this.dataModelObject.fieldByName(fieldName);
            if (utils.contains(["string", "ipv4"], f.type) &&
                !utils.contains([
                    "list",
                    "values",
                    "first",
                    "last",
                    "count",
                    "dc"], statsFunction)
                ) {
                throw new Error("Stats function on string and IPv4 fields must be one of:" +
                    " list, distinct_values, first, last, count, or distinct_count; found " +
                    statsFunction);
            }
            else if ("number" === f.type && 
                !utils.contains([
                    "sum",
                    "count",
                    "average",
                    "min",
                    "max",
                    "stdev",
                    "list",
                    "values"
                    ], statsFunction)
                ) {
                throw new Error("Stats function on number field must be must be one of:" +
                    " sum, count, average, max, min, stdev, list, or distinct_values; found " +
                    statsFunction
                    );
            }
            else if ("timestamp" === f.type &&
                !utils.contains([
                    "duration",
                    "earliest",
                    "latest",
                    "list",
                    "values"
                    ], statsFunction)
                ) {
                throw new Error("Stats function on timestamp field must be one of:" +
                    " duration, earliest, latest, list, or distinct values; found " +
                    statsFunction
                    );
            }
            else if (utils.contains(["objectCount", "childCount"], f.type) &&
                "count" !== statsFunction
                ) {
                throw new Error("Stats function on childcount and objectcount fields must be count; " +
                    "found " + statsFunction);
            }
            else if ("boolean" === f.type) {
                throw new Error("Cannot use boolean valued fields as cell values.");
            }

            this.cells.push({
                fieldName: fieldName,
                owner: f.lineage.join("."),
                type: f.type,
                label: label,
                sparkline: false, // Not properly implemented in core yet.
                value: statsFunction
            });

            return this;
        }
function(fieldName, label, statsFunction) {
            if (!this.dataModelObject.hasField(fieldName)) {
                throw new Error("Did not find field " + fieldName);
            }

            var f = this.dataModelObject.fieldByName(fieldName);
            if (utils.contains(["string", "ipv4"], f.type) &&
                !utils.contains([
                    "list",
                    "values",
                    "first",
                    "last",
                    "count",
                    "dc"], statsFunction)
                ) {
                throw new Error("Stats function on string and IPv4 fields must be one of:" +
                    " list, distinct_values, first, last, count, or distinct_count; found " +
                    statsFunction);
            }
            else if ("number" === f.type && 
                !utils.contains([
                    "sum",
                    "count",
                    "average",
                    "min",
                    "max",
                    "stdev",
                    "list",
                    "values"
                    ], statsFunction)
                ) {
                throw new Error("Stats function on number field must be must be one of:" +
                    " sum, count, average, max, min, stdev, list, or distinct_values; found " +
                    statsFunction
                    );
            }
            else if ("timestamp" === f.type &&
                !utils.contains([
                    "duration",
                    "earliest",
                    "latest",
                    "list",
                    "values"
                    ], statsFunction)
                ) {
                throw new Error("Stats function on timestamp field must be one of:" +
                    " duration, earliest, latest, list, or distinct values; found " +
                    statsFunction
                    );
            }
            else if (utils.contains(["objectCount", "childCount"], f.type) &&
                "count" !== statsFunction
                ) {
                throw new Error("Stats function on childcount and objectcount fields must be count; " +
                    "found " + statsFunction);
            }
            else if ("boolean" === f.type) {
                throw new Error("Cannot use boolean valued fields as cell values.");
            }

            this.cells.push({
                fieldName: fieldName,
                owner: f.lineage.join("."),
                type: f.type,
                label: label,
                sparkline: false, // Not properly implemented in core yet.
                value: statsFunction
            });

            return this;
        }
function ( fieldName , label , statsFunction ) { if ( ! this . dataModelObject . hasField ( fieldName ) ) { throw new Error ( "Did not find field " + fieldName ) ; } var f = this . dataModelObject . fieldByName ( fieldName ) ; if ( utils . contains ( [ "string" , "ipv4" ] , f . type ) && ! utils . contains ( [ "list" , "values" , "first" , "last" , "count" , "dc" ] , statsFunction ) ) { throw new Error ( "Stats function on string and IPv4 fields must be one of:" + " list, distinct_values, first, last, count, or distinct_count; found " + statsFunction ) ; } else if ( "number" === f . type && ! utils . contains ( [ "sum" , "count" , "average" , "min" , "max" , "stdev" , "list" , "values" ] , statsFunction ) ) { throw new Error ( "Stats function on number field must be must be one of:" + " sum, count, average, max, min, stdev, list, or distinct_values; found " + statsFunction ) ; } else if ( "timestamp" === f . type && ! utils . contains ( [ "duration" , "earliest" , "latest" , "list" , "values" ] , statsFunction ) ) { throw new Error ( "Stats function on timestamp field must be one of:" + " duration, earliest, latest, list, or distinct values; found " + statsFunction ) ; } else if ( utils . contains ( [ "objectCount" , "childCount" ] , f . type ) && "count" !== statsFunction ) { throw new Error ( "Stats function on childcount and objectcount fields must be count; " + "found " + statsFunction ) ; } else if ( "boolean" === f . type ) { throw new Error ( "Cannot use boolean valued fields as cell values." ) ; } this . cells . push ( { fieldName : fieldName , owner : f . lineage . join ( "." ) , type : f . type , label : label , sparkline : false , // Not properly implemented in core yet. value : statsFunction } ) ; return this ; }
Add an aggregate to each cell of the pivot.

@param {String} fieldName The name of field to aggregate.
@param {String} label a human readable name for this aggregate.
@param {String} statsFunction The function to use for aggregation, see class docs for valid stats functions.
@return {splunkjs.Service.PivotSpecification} The updated pivot specification.

@method splunkjs.Service.PivotSpecification
Add an aggregate to each cell of the pivot .