Aggregate

Aggregates an incoming data set by the desired level for all numeric properties specified in the payload.

Version 1

HTTP Request
POST /ado/v1/Aggregate

Header

ParameterDescription
Ocp-Apim-Subscription-KeyThe subscription key you received when you purchased a plan.

Request Body

Mandatory

ParameterTypeDescription
aggregationTypeStringThe aggregation operation to perform. Must be one of the following values … Sum, Count, Avg, Max or Min
aggregateByString[]The properties to include in the resulting aggregation.

Supports the dynamic property selection syntax.

Dynamic Property Selections
aggregateOnString[]The numeric fields to aggregate on. The operation parameter indicates the type of aggregation performed.

Supports the dynamic property selection syntax.
dataObject[]Array containing one or more single level objects.

Common

Further Documentation: Common Parameters

ParameterTypeDescription
filterStringA fully functioning SQL based WHERE statement that will filter the outgoing dataset to the records it determines as being included.
sortOrderObjectSorts the resulting dataset by the criteria provided.
The object should contain property names that represent properties contained within the resulting dataset with a value corresponding to the desired sort direction (i.e. ASC or DESC).
schemaObjectYou can use this parameter to override the inferred schema for properties in the incoming dataset(s).
A field will be inferred unless specific explicitly within this object.
advancedOptionsObjectIs an object with the following properties.

cultureName (String)
The specified culture determines the behaviour for aspects related to formatting numeric values and dates. Is extremely important when converting strings to dates, e.g. 05/03/2022 will be treated differently between locales. For more information on the accepted values for this property, please consult the documentation from Microsoft … https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=net-6.0#culture-names-and-identifiers

isBoolean (string[])
A list of strings that are the names of all properties in the resulting dataset that should be treated as boolean values.

By default, the framework treats boolean values as 1 (true) or 0 (false). In order to differentiate the integer as a boolean, the property in question needs to be called out explicitly in this list.

Examples

Sum
Avg

This example loads in a basic Cost Centre by G/L Account data set and aggregates (using a SUM) on all properties (using the dynamic property selection functionality) except for the Amount property.

If an additional property was included in the dataset which also needed to be included in the aggregation, it would happen automatically with no change needed to the aggregateBy property.

Request

{
    "aggregationType": "Sum",
    "aggregateBy": [
        "+FieldName(%)",
        "-FieldName(Amount)"
    ],
    "aggregateOn": [
        "Amount"
    ],
    "data": [
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "Amount": "96.1"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "Amount": "31.2"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "Amount": "69.2"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6001",
            "Amount": "57.9"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6001",
            "Amount": "70.8"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "38.4"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "9.8"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "97.1"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "16.4"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "84.6"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "39.1"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "13.9"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "46.8"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6001",
            "Amount": "41.7"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6002",
            "Amount": "27.9"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6002",
            "Amount": "87.4"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6002",
            "Amount": "16.7"
        }
    ]
}
Code language: JSON / JSON with Comments (json)

Response

[
    {
        "CostCenter": "CC_1000",
        "GLAccount": "CE_6000",
        "Amount": 196.5
    },
    {
        "CostCenter": "CC_1000",
        "GLAccount": "CE_6001",
        "Amount": 128.7
    },
    {
        "CostCenter": "CC_1000",
        "GLAccount": "CE_6002",
        "Amount": 161.7
    },
    {
        "CostCenter": "CC_2000",
        "GLAccount": "CE_6000",
        "Amount": 184.4
    },
    {
        "CostCenter": "CC_2000",
        "GLAccount": "CE_6001",
        "Amount": 41.7
    },
    {
        "CostCenter": "CC_2000",
        "GLAccount": "CE_6002",
        "Amount": 132.0
    }
]
Code language: JSON / JSON with Comments (json)

This example loads in a basic Cost Centre by G/L Account data set and aggregates (using AVG) on the CostCenter property.

The aggregateBy selection is undertaken by hardcoding the relevant property name(s).

Request

{
    "aggregationType": "Avg",
    "aggregateBy": [
        "CostCenter"
    ],
    "aggregateOn": [
        "Amount"
    ],
    "data": [
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "Amount": "96.1"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "Amount": "31.2"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6000",
            "Amount": "69.2"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6001",
            "Amount": "57.9"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6001",
            "Amount": "70.8"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "38.4"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "9.8"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "97.1"
        },
        {
            "CostCenter": "CC_1000",
            "GLAccount": "CE_6002",
            "Amount": "16.4"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "84.6"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "39.1"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "13.9"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6000",
            "Amount": "46.8"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6001",
            "Amount": "41.7"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6002",
            "Amount": "27.9"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6002",
            "Amount": "87.4"
        },
        {
            "CostCenter": "CC_2000",
            "GLAccount": "CE_6002",
            "Amount": "16.7"
        }
    ]
}
Code language: JSON / JSON with Comments (json)

Response

[
    {
        "CostCenter": "CC_1000",
        "Amount": 54.1
    },
    {
        "CostCenter": "CC_2000",
        "Amount": 44.7625
    }
]
Code language: JSON / JSON with Comments (json)