Aggregate and grouping reference
Section titled “Aggregate and grouping reference”This page is for integrators and developers who read totals or grouped lists through the API, build a client that renders them, or need the exact rules behind the figures. It states every rule the server enforces, the reason it holds, and the routes.
Two features work together, computed by OSOS in a single pass on the server:
- An aggregate is a saved “field + function” definition — Sum of Amount, Count of entries — created once on an entity and switched on for the views that should show it.
- Grouping splits an entries list into blocks by the value of a field. Each block carries its own subtotals, and the list as a whole carries a grand total.
Lifecycle
Section titled “Lifecycle”An aggregate takes effect immediately. There is no publish step, because an aggregate is a resource of its own rather than part of the entity’s structure, so it never queues behind the entity’s own update cycle. It still travels with the entity when you package one: exporting an entity carries its aggregates along, and deleting the entity takes them with it. Deleting a single aggregate removes it from every view that had enabled it, silently and without an error — those views keep working, they simply stop showing that figure.
Functions and the fields they accept
Section titled “Functions and the fields they accept”There are exactly five functions: Count, Sum, Min, Max, and Average. Note the spelling — the platform says Average, never “avg”, and there is no median, distinct-count, first, last, or standard deviation.
Which of them you may choose depends only on the field:
| The field is… | You may choose |
|---|---|
| A Number field | All five |
| Any other field type | Count only |
| An encrypted field | Nothing at all — the field is refused, Count included |
Why Count survives on a non-numeric field: unlike the other four, Count doesn’t need to read a number out of the field to add up, compare, or divide — it only checks whether the field has a value at all. That is what makes it meaningful over a text, date, or reference field where a sum would not be, and it is also why Count’s number is not simply a row count: an entry with no value for the counted field does not contribute to it, the same way it would not contribute to a Sum or an Average over that field. Since 1.10 — before that release, Count quietly ignored the field it was configured on and counted every matched entry regardless, so a Count and an Average defined on the same field could report inconsistent populations; now both agree on what “no value” means.
Why an encrypted field is refused outright, rather than masked: the stored value is ciphertext, so there is no real number behind the mask — nothing to withhold, only nonsense to compute. The refusal happens when you save the definition, not quietly at read time. A field in the middle of having encryption switched off is refused for the same reason, because entries not yet migrated still hold ciphertext.
A mapped field behaves exactly like a plain field of its own type — the mapping changes nothing about which functions are allowed. A field inside a block can be aggregated (the block’s leaf fields are offered, flattened out of the block); the block container itself cannot.
There is no cap on how many aggregates an entity may have, and no rule that a field gets only one: Sum of Amount and Average of Amount can both exist, and a list renders them stacked in the same cell. Give each a display name — an unnamed aggregate falls back to the field’s own name, which reads badly when two of them target the same field.
Defined once, enabled per view
Section titled “Defined once, enabled per view”The definition belongs to the entity. The decision to show it belongs to each view, as a checkbox list on the entries-list card.
A view that enables none gets none. It does not inherit the entity’s set, and it does not acquire an aggregate later because somebody added one to the entity. That intersection is a deliberate boundary, not a convenience: OSOS resolves the aggregates a request may compute by intersecting what the caller asked for with what the view enabled, and it does so on the server. So a client cannot widen the set by asking for more, and a published or anonymous-facing view cannot start disclosing a new total behind your back.
The cost of that guarantee is real and worth planning for: a newly created aggregate is invisible until you go and enable it on each view that should carry it. There is no “all views” switch.
Two consequences that follow from the same rule:
- In the admin section — browsing an entity’s own entries with no view bound — every aggregate defined on the entity is computed, because there is no view to narrow by.
- A deleted aggregate is dropped leniently. Views that enabled it are not rewritten and do not error; the id simply stops resolving.
Grand total and per-group subtotals
Section titled “Grand total and per-group subtotals”Both figures are computed on the server, in one pass, for every platform. Neither is a client-side roll-up of what is on screen.
- The grand total is computed over everything the list matches — every entry left after filters, search, quick filters, filter-first, entry state, and store access — not over the rows on the current page, and not over the page of groups being displayed.
- Each group carries the same aggregates again as its own subtotal, over that group’s entries.
The summary inherits the entries list’s own scope rather than rebuilding it, so a total can never count a row the list itself would refuse to show.
Two things follow that surprise people:
- Paging changes nothing. Moving to page 4 does not change the grand total, because it was never a total of the visible rows.
- The subtotals on screen do not add up to the grand total in the general case. Summing group sums works; averaging group averages does not, and neither does anything computed over one page of groups.
When grouping produces exactly one group, the list leaves the grand-total row out — it would repeat that group’s subtotal verbatim.
A blank, a dash, and ****
Section titled “A blank, a dash, and ****”Three different answers, which a builder must not conflate:
| What appears in the cell | What it means |
|---|---|
- (a blank cell, rendered as a dash) | There was nothing to total. No matching entries, or none of them holds a value for that field. An average over no rows is not zero, and a minimum over an empty set has no answer, so the platform declines to invent one. |
0 | A genuine zero — a real computed result. |
**** | Computed, then withheld. The field is protected and this reader may not see the value. See Protected fields. |
Never read - as “hidden”, and never read **** as “empty”. The platform keeps the two apart deliberately, and never puts a presentation string into a data field, so an integrator reading the API sees the same distinction: an absent value and a withheld value are separate flags.
Preview mode
Section titled “Preview mode”In preview mode, a summary response always comes back with matchedCount: 0, every aggregate showing -, and no groups — but a field that would be masked for the previewing caller is still reported as masked. A plausible fake number would be worse than an obvious blank, so preview never invents one; and because the masking verdict is still computed correctly, preview never shows an aggregate the live response would have withheld or dropped entirely.
Grouping configuration rules
Section titled “Grouping configuration rules”- Grouping levels (Add Group By) — an ordered list of fields. The first level is the outermost block, the next splits inside it, and so on. A field can only be picked once, and there is no cap on how many levels you add.
- Collapse groups by default — every block opens collapsed the first time a reader sees the list. Off by default.
- User change grouping — end users may choose their own levels from the list’s own View settings panel. Off by default. While it is off, a reader can neither add a level nor clear one; the view’s own configuration is all they get.
Turning the entries-list card off only hides these settings in the designer. Nothing clears them, so a disable/re-enable round trip returns them untouched.
One rule constrains what you can save: a grouping level must be one of the view’s own listed fields. Grouping by a field the view does not list would surface a column you deliberately hid, so that configuration is refused — including for a protected field, where collapsing the level (below) is not a license to reach a field the view never listed.
Which fields can be grouped, and why
Section titled “Which fields can be grouped, and why”You can group by text, localized text, number, date, category, switch, a single-value reference, a mapped field, and any field inside a non-repeating block.
Four kinds of field cannot be grouped. It is worth knowing that these are impossible, not merely unimplemented — each one breaks something the feature has to guarantee:
| The field… | Why grouping cannot work |
|---|---|
| holds several values at once | The entry belongs in more than one block at the same time. |
| repeats | Same: one entry, several values, several blocks. |
| sits inside a repeating block | Same again — the entry carries one value per repetition of the block. |
| is a lookup / ADT field | Its stored value is an option id resolved against the field’s own lookup list, not a pointer to an entry, so there is nothing in the value for grouping to key on. |
The first three fail for one shared reason. A list can only draw an entry in one place, so a block boundary cannot hold an entry that belongs to three of them at once — and worse, the entry count and every subtotal would count that entry once per block it landed in, so the group counts would stop adding up to the list’s own count. A non-repeating block is fine: it holds exactly one value per entry, so none of that arises.
The fourth fails differently. A lookup/ADT field looks like a reference — it is the same underlying type — but grouping it the way a reference is grouped would read a part of the value that does not exist on any entry, quietly dropping every entry into a single empty-keyed block with no error at all to notice it by. Excluding it outright is the honest outcome.
The entry’s meta-data block and its children are excluded too — they are virtual, assembled per request rather than stored. The designer’s field picker additionally leaves out ranged fields, which hold a from/to pair rather than one value.
Multi-value category fields Since 1.10
Section titled “Multi-value category fields Since 1.10”A category field can now be set to hold several values (an array of options rather than one). Such a field falls under the first row of the table above — an entry holding A and B would belong in two blocks — so it cannot be a grouping level. The rule is checked twice: when the view is saved, and again when the summary is read, because a category field can be switched to multi-value after a view that groups by it was saved; that view’s grouping then stops applying rather than double-counting.
The same field is refused in the neighbouring places that need exactly one value per entry: a view’s default sort, a dashboard statistic’s group-by, a Kanban column or sub-category field, a timeline category, and the entity’s main / sub category (error MULTI_VALUE_CATEGORY_FIELD_NOT_ALLOWED, with details.usage naming the place). The reverse is guarded too: switching an existing category field to multi-value while any of those uses it fails with CATEGORY_FIELD_MULTI_VALUE_IN_USE, so clear the usages first. See Data Views & Faces for the view-side settings.
Grouping by a reference field
Section titled “Grouping by a reference field”Grouping by a single-value reference is fully supported, and behaves a little differently from a plain field:
- The block’s key is the related entry itself, so you can reuse the key as a filter value without knowing how a reference is stored.
- The block’s label is that related entry’s main title, resolved on the server as part of the same query — one lookup per block, not per row.
- If the related entry has been deleted or archived, or lives in a store this reader cannot open, the block keeps its entries and simply shows no label. That is not an error, and it is deliberate: the entries in that block are readable — that is why the block exists — so dropping the whole block to hide a title would hide data the reader is entitled to.
- Block order for a reference level follows the resolved label. Unlike a category or switch level, a reference has no designer-configured option order to fall back on.
- Ordering the rows by the reference’s label needs a per-request pass over the distinct related entries, and that pass is capped at 500 distinct related entries. Past the cap the list still groups correctly and still totals correctly — only the label-based row sequence within that level is lost.
Grouping by a localized text field
Section titled “Grouping by a localized text field”A localized text field can be grouped, and it groups on the language the reader is reading in.
The practical consequence is worth stating plainly to whoever asks for this view: two people reading the same list in different languages see different group keys, and can even see a different number of blocks — when two entries share an English value but differ in Arabic, they group together for one reader and apart for the other. This is the same convention the platform already applies when sorting a localized field, which is what keeps a grouped list’s blocks agreeing with the order its rows are drawn in.
Because the key is the text, there is no separate label to resolve. An entry with no value in the reader’s current language falls into that reader’s “no value” block.
Whose grouping wins, and how long it lasts
Section titled “Whose grouping wins, and how long it lasts”The rule is unambiguous, and the two halves are different in kind:
- The designer’s configuration is durable, and always wins on load. It is stored on the view like any other view setting, so every reader who opens the view starts from it.
- A reader’s own grouping is theirs alone, and lasts only for the session. Nothing about it is stored on the server, and reopening the view in a fresh context brings back the view’s configured grouping — the reader’s choice reverts on reopen.
What “the session” means in practice, for a reader who chose their own grouping:
| Event | Their choice survives? |
|---|---|
| Reloading the page | Yes |
| Navigating away inside the portal and back | Yes |
| A new browser tab or window | No |
| Signing out | No |
| A different device, or a later visit | No |
| You edit the view’s grouping | No — their choice is dropped |
That last row matters when you change a view: nobody is left reading a grouping that no longer matches the view they are looking at. An earlier revision did persist a reader’s grouping on the server, where it outranked every later edit you made to the view — permanently, with the reader’s list and your own preview disagreeing. That behaviour is gone; the view’s configuration is now the only durable source.
How group blocks are ordered
Section titled “How group blocks are ordered”Sorting a grouped list orders the blocks as well as the rows inside them:
- With no sort applied, blocks follow the group key’s own order — the option order you configured for a category or switch level, the resolved label for a reference level.
- Once a reader sorts, each block is ordered by one value taken from the sorted field: the highest value in the block for a descending sort, the lowest for an ascending one. That is the value that would sort first inside the block under the reader’s own direction; any other choice would put a block ahead of one that visibly contains a higher-sorting row, and grouping would look as though it had discarded the sort.
- Only the primary sort field orders the blocks. A second sort field still orders rows inside a block, but ordering blocks by a value most of them do not differ on would order nothing.
- The ordering value is computed only over the rows the reader can actually see — after filters, search, quick filters, permissions, and filter-first. A row that was filtered out cannot drag its block to the top of the list, and the block headers cannot end up in a different order from the row blocks beneath them.
Protected fields
Section titled “Protected fields”Aggregates and grouping both respect field-level protection, and each does so in the way that discloses least. See Sensitive Fields for how a field becomes sensitive or encrypted, and how grants and reveal sessions work.
- An aggregate over a sensitive field still appears, under its display name, with its value withheld as
****. Removing it would itself be a disclosure — its absence would tell the reader that the field exists and is protected. The reader learns that a figure exists and that they may not have it, which is the intended amount. - An aggregate over an encrypted field is not offered at all — you cannot define one, so there is nothing to mask. There is no number behind the mask to withhold.
- Grouping on a protected field — sensitive or encrypted — collapses into exactly one masked group, labelled
****, holding every matching entry, with that block’s count and subtotals covering the whole matched set.- It is uniform for everyone: a reader holding the field’s grant with an active reveal session sees the same single block as an anonymous visitor. Grouping is a shared, saved view setting rather than a per-reader one, so per-viewer groupability and shared configuration cannot both hold.
- Entries with no value for the field land in that same block, deliberately, rather than in a separate empty-value block beside it. A separate block would tell every reader which records have the field filled in — and for a salary, medical, or disciplinary field, that is often the sensitive fact itself.
- A single block also discloses nothing about the field’s shape: not how many distinct values exist, not how the population spreads across them, and not their relative order — all of which a set of masked block headers would have leaked.
- Such a level is valid, saveable configuration; OSOS no longer refuses it. It renders, it simply renders uselessly, which you can see in the designer and undo.
- On a view an anonymous visitor can open, an aggregate over a sensitive field is dropped whole rather than masked — the platform withholds even the definition, because its id, display name, and field name all describe a sensitive field to someone it cannot attribute anything to.
In the designer, the grouping picker offers a sensitive field (it collapses as above) but hides an encrypted field, or one mid-way through being encrypted; a level saved earlier on such a field still collapses and is flagged in the designer as no longer available.
API surface
Section titled “API surface”Every response below arrives inside the usual {success, result} envelope — see Calling the HTTP API.
Aggregate definitions
Section titled “Aggregate definitions”| Method | Path | Purpose |
|---|---|---|
POST | /v1/entities/{entity}/aggregates | Create an aggregate on the entity |
GET | /v1/entities/{entity}/aggregates | List the entity’s aggregates (unpaginated) |
PATCH | /v1/entities/{entity}/aggregates/{id} | Update one — a partial body is fine |
DELETE | /v1/entities/{entity}/aggregates/{id} | Delete one; views that enabled it drop it leniently |
{entity} accepts either the entity id or its normalized name. |
There is no server-side copy route Removed 1.10. Pre-release 1.10 builds carried POST /v1/entities/{entity}/aggregates/{id}/copy; it was dropped before release. The designer’s Copy now opens the create dialog pre-filled from the original (its name suffixed ” - Copy”) and saves through the ordinary POST /v1/entities/{entity}/aggregates, so an integrator copies an aggregate the same way: read it, then create a new one with the same field, aggregationFunction and name.
The entries summary
Section titled “The entries summary”The totals and the group headers come from one response, on whichever of three GET routes matches the context:
| Route | Context |
|---|---|
/v1/entities/{entity}/entries/summary | The admin section, with no view bound |
/v1/entities/{entity}/views/{id}/entries/summary | A published view or a portal gallery |
/v1/entities/{entity}/entries/{entryId}/relations/{relationId}/summary | A related-entries list |
They share these query parameters: aggregates, groupBy, groupSkip, groupLimit, filterCriteria, search, include_virtual, and appliedQuickFilters. The view-scoped route also takes filterFirst and parameters; the entity-wide route also takes collectionId.
- Which route you call is a security boundary, not a convenience: the view-scoped route narrows the aggregates to the view’s enabled set, and the entity-wide route does not.
aggregatesis intersected with the view’s enabled set, never unioned. Omitting it means “the view’s enabled set”; sending it empty means “none” — those are different answers.groupByis honoured only when the view allows end-user grouping; otherwise the view’s own levels are used. Sending it empty does not mean “ungrouped” — an empty list falls back to the configured levels, which is why the product’s own clients suppress grouped rendering on their side instead.groupSkip/groupLimitpage the group headers for an integrator that asks for them. Neither the web nor the mobile client ever sends them, so do not design a view around group pagination — plan instead for a grouping level with a manageable number of distinct values.
The same optional groupBy parameter exists on the v3 entries-listing routes. There it changes nothing about what comes back, only the order, so every entry of a group arrives together — which is what a subheader-style grouped table needs in order to draw one header per block.
The end-user view load
Section titled “The end-user view load”GET /v2/views/end-user/{id} carries availableAggregates — the aggregate definitions (id, name, field, function) a gallery needs in order to build its own Aggregator checklist, since an aggregate toggled off has no computed value to be listed from. The older GET /v1/views/end-user/{id} does not carry it.
This list is already narrowed on the server — it is the view’s enabled set minus anything this caller may not have. Do not re-intersect it against the view’s own aggregates array: an id can legitimately be in the view’s configuration and absent here, and re-filtering would only reintroduce a disagreement the server has already resolved. If resolving the list fails, it comes back empty rather than failing the view load.
Not covered by any endpoint: the entries export carries neither grouping nor totals — the XLSX export has no groupBy and no aggregates parameter, and a template export renders entries, not summaries. That holds for every export path, including the 1.10 gallery quick export (XLSX or CSV — see Data Views & Faces): a groupBy sent to it only orders the rows so each group’s entries are adjacent; it writes no group headers and no totals. If a total has to leave the platform, compute it from a summary call rather than expecting it in the file.
Version notes
Section titled “Version notes”Everything on this page — the aggregate definitions, enabling them per view, entry grouping, the summary routes, and availableAggregates — is Since 1.10. None of it is present in 1.8 or any earlier release. The one fix worth calling out on its own: Since 1.10, Count was corrected to count entries that have a value for the configured field, rather than every matched entry regardless of the field’s value — see Functions and the fields they accept above.
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27