Data
References and history
How Konstrukt keeps a full change history of value-type data, the two kinds of reference (stored data and point-in-time), how they are queried in Kex and used in apps, and what deleting data does and does not remove.
Konstrukt keeps every earlier version of value-type data. References give names to versions you want to compare against, such as an approved budget, last month's forecast or the state before a reorganisation. There are two kinds of reference, and the difference between them follows from how history works.
History#
All changes to value-type data are kept in system-versioned history. Each version of a row keeps its value and the period during which it was current.
- History is change-based, not write-based. If a calculation or import writes the same value that is already stored, the row counts as unchanged and no history row is created. A recalculation that produces the same result leaves history untouched. This keeps point-in-time views stable across repeated recalculations, and makes history record what changed rather than what was recomputed.
- History covers user entries, imports, actions and calculations alike. Each version carries its edit time, who made the edit and the writing calculation.
Querying history#
In Kex, from history reads data as it was at a given moment:
Amount from history '2026-03-31 23:59'
Amount from history now() - days(7)
Amount from history startofmonth() - milliseconds(1) values only
| Form | Behaviour |
|---|---|
from history <datetime> |
Value-type data and dimensions as they were at that moment |
from history <datetime> values only |
Historical value-type data, but current dimensions; historical rows that refer to dimension values since removed are filtered out |
from history can be combined with from plan and from reference.
The external SQL views support the same idea with for system_time as of. See APIs and SQL access.
Two kinds of reference#
| Data reference | Point-in-time reference | |
|---|---|---|
| Swedish GUI | Referens | Tidpunkts-referens (clock icon) |
| Stores | Its own copy of data | Only a timestamp |
| Content | Whatever is written to it: imported, copied or calculated | The plan's data as it was at the timestamp, read from history |
| Creation cost | Proportional to the data written | Instant, whatever the data volume |
| Can be changed after creation | Its data can be rewritten | The timestamp can be edited, which changes the whole content |
| Typical use | Actuals from another system, approved budgets, external benchmarks | "As of month-end close", "last week", "before the reorganisation" |
The type is fixed when the reference is created. A data reference cannot be converted into a point-in-time reference, or the other way round.
Point-in-time references#
A point-in-time reference is a named query against history. Because it stores only the timestamp:
- it is retroactive: you can create a reference for a moment that has already passed, with no preparation done at that moment;
- editing its timestamp immediately changes its entire content, and nothing needs to be rebuilt;
- it costs no storage.
The timestamp is entered in local time. The interface shows the time zone explicitly, for example (lokal tid GMT+02:00).
In Kex, reading a point-in-time reference with from reference is rewritten automatically to from history <timestamp> values only. The query diagnostics show this step as Rewrite point-in-time references.
Data references#
A data reference holds its own rows for any value type in the plan. You can write to it in the following ways:
- with Kex:
write to Amount reference "Budget approved" <- …; - with an import configuration or MCP import tool that targets the reference;
- with a calculation that writes reference data.
Deleting a data reference deletes its data.
Creating and managing references#
References belong to a plan. You create them from the view selector on a value type (Ny referens) or from the reference panel on the value-type list:
- Give the reference a name.
- Optionally tick Skapa tidpunkts-referens (create point-in-time reference) and choose a date and time.
The reference is available immediately. The reference panel shows each reference's ID, its timestamp (for point-in-time references), and the value types and apps that use it. Deleting a reference cannot be undone.
References in Kex#
Compare plan data with a named reference:
var Budget = Amount from reference "Budget approved"
Diff = sum(Amount) - sum(Budget)
Write reference data:
write to Amount reference "Budget approved" <- Amount
A reference can be addressed by ID or by name. See Kex.
References in apps#
In apps, plan data and references are combined in a virtual data type dimension. For each workspace you choose which data types are shown:
- Plan data can be selected, hidden, required or allowed.
- Each reference can be the default, available or unavailable.
This lets a user switch a table between plan data and, for example, last month's forecast, or show them side by side. Initial values can also be generated from reference data. See Workspaces and components and Datasets.
Data type codes in the app configuration are Plan, Reference_<id>, or a custom code.
What deleting data does to history#
| Operation | Current data | History |
|---|---|---|
| Change a value | Updated | Previous version kept |
| Delete value-type rows (user, import, Kex, MCP) | Removed | Previous versions kept |
| Remove a dimension value's data via Kopplingar | Removed from the chosen value types | Previous versions kept |
| Delete a dimension value | Removed from the dimension | Previous versions kept; historical rows referring to it are filtered out of values only reads |
| Empty a value type to change its dimensions | Removed | Removed |
| Delete a data reference | Its data removed | — |
Data removal and history
Deleting data does not remove it from history. Earlier versions stay readable through from history and point-in-time references for as long as the value type keeps its history.
Retention#
History is currently kept until further notice. No specific retention period is guaranteed. Limits may be introduced for storage reasons, and may in future depend on the licence. History can be removed:
- for one value type, by emptying it and changing its dimensions, which rebuilds its table; or
- for a whole plan, by copying the plan (history tables are not copied), then archiving and deleting the original. Point-in-time references in the copy are then empty.
Pitfalls for agents
See the Agent guide for what deletion does and does not remove, and how point-in-time references are rewritten.