/api/statistics

The statistics endpoint is used to retrieve data that is not directly available through regular GET queries on entities. The typical use case is retrieving data for reports or dashboards where you need to apply an aggregate function on the data.

The endpoint uses regular ODATA syntax most of the time, but has been expanded to provide more functionality. The endpoint is used by specifying:

Hateoas

Retrieving hateoas through the statistics endpoint uses the same analysis as the regular controllers, but to be able to retrieve hateoas data you need to retrieve the ID and StatusCode of the main model being used. I.e. you cannot retrieve a summary of invoices summed by customer, and also expect to get hateoas data for the invoices.

Examples

Retrieve latest auditlog entries, and join in user

Retrieve all JournalEntryLines, expand Account and Account.AccountGroup

Retrieve all JournalEntryLines, expand Account and sum Amount debit, Amount Credit and Amount total

Retrieve sum amount from JournalEntryLines grouped by accountnumber. Specify “MySpecialSum” as an alias for the sum

If you do not specify an alias for a field/function, an alias will be created automatically. For fields, the alias will be “EntityNameFieldName”, e.g. AccountAccountName in the previous example. For functions, all none alphanumerical characters will be removed, so the name in this example would be sumamount. For more complex functions you might end up with something like “sumcasewhenPeriodAccountYearlt2016amount0”. So use aliases (smil) Retrieve list of suppliers and their bankaccounts shown in a stuffed list in one column

When using the stuff function you need to add the ID of the main model to the select, because the stuff function will cause a grouping and a subselect using this ID Using functions in select/filter

As the examples above demonstrate, you can also use functions to aggregate data. If a summary function is used (i.e. a function that requires that a group by is applied), this is automatically added. For functions with multiple parameters, remember to escape the “,” with a backslash, e.g. “casewhen(amont gt 0\, amount\, 0)” These are the features that are currently supported: