Skip to content

Written for: For developers

Governed objects

12 min read · Updated 17 Nov 2026

A governed object takes its dimensions, measures, order and calculations from the semantic layer. The app adds presentation only: chart type, colours, formats and display names. Anyone who queries the layer, through MCP, another app or a workbook, then gets the same figure the dashboard shows.

Every number on the page should come from a governed measure, either in a mounted object or in a query of a stored measure. Do not compute figures in the app from query results: no averages over fetched rows, no ratios of two query results, no recalculated per-row ratios. Such a figure has a second definition that can drift from the layer’s and cannot be reused.

Many figures need nothing new in the layer. An average of a published measure per order, customer or other finer grain is computed on the object itself; see Averages at a finer grain. When no published item gives the value, add it to the layer:

The page needs Add to the layer
A new formula, such as a ratio of two sums A measure, such as SUM(a) / SUM(b)
A count of rows meeting a condition A 0/1 flag column in the view and a SUM measure over it
A per-row ratio that a slider compares against A column in the view (computed in the warehouse) that a selection can range over
A comparison with an earlier period A period-comparison measure; see Earlier periods
A headline that must ignore a page control A measure whose aggregate inputs carry a filter, pinned to one slice (below)
A what-if scenario or sensitivity Rows per scenario and assumption set in the view, switched by a selection (below)

The app may still compare a stored per-row value with a control’s value, for example to badge one application as passing or failing a threshold, because that is presentation of a governed value, not a new figure.

In the App Builder preview and in a published App, objects read the published layer. A measure you add stays in the layer’s draft until the layer is published, and until then those objects cannot show it. Say so before building an object on a new measure, and publish the layer, or ask its owner to, before you rely on the object.

Write one business question per object, or per family of objects that share a shape, such as all headline cards. Give every dimension and measure selection a key. The keys become the object’s refs: the app names the question and the keys it keeps, and takes the field names, order and calculations from the question.

A Data App cannot read business questions at runtime (see Querying the engine). Copy the stored questions into the app as data at build time, with a script that reads them through the MCP server (astrato_semantic_layer_list_questions, then astrato_semantic_layer_get_question) and writes a module. Re-run the script whenever a question changes, and keep the script beside the app.

// questions.js — generated; do not edit by hand.
export const QUESTIONS = {
region: {
id: 'How do income and expenses compare by region?',
dimensions: [{ key: 'd_region', dimension: 'Region' }],
measures: [
{ key: 'inc', measure: 'Avg Monthly Income' },
{ key: 'exp', measure: 'Avg Total Expenses' },
],
orderBy: [{ key: 'inc', direction: 'descending' }],
},
};

The module can also be the source rather than the output: author the questions there as data and commit them through the MCP batch tools, so a prompt the app offers and the stored question it runs cannot drift apart.

Resolve each name against live metadata: a stored dimension through its [dimension] item, a stored measure through its [calculation] item. Build the visualization definition from those fields with the question’s keys as refs and its orderBy as the sorting. A name that does not resolve fails only the object that needs it: show that object’s error state and let the rest of the page load, as Check operation results shows. When a question measure carries interRecord, apply the matching setMeasureAdvancedCalculationType and setMeasureAdvancedOffset operations to that measure.

Execute every question through MCP once after publishing. A question that returns one row with a null dimension value usually means the dimension’s column is empty in the data, not that the question is wrong.

A question’s next business questions can sit behind a light bulb in the top-right corner of its chart, beside SQL. On a first build, App Builder adds them to the main chart when Nash saved the main question, created its next questions and can chart at least one with what it explains. Selecting the light bulb lists the next questions by their wording; selecting one shows its chart in the main chart’s place, with the question’s wording and Back above it. Only the chosen chart runs, and the main chart keeps its selections underneath.

Where Nash builds an entry, it is a live chart built like any other object on published items. It must show what the question explains: for a change between periods, the change itself for each member, as one measure, never two values the reader must subtract; for a share of the total, each member’s share. A question’s measure alone explains nothing. Where the measure isn’t published yet, add it to the layer’s draft, for a change as a period comparison of type Difference on the question’s measure, and add the question at once, listed only while every field its chart needs is in availableFields, where a stored item appears by its name once it is published, so it appears the next time the app loads after the layer is published, because the app reads only published items. A question whose measures the search saved to the draft, such as a distribution, is handled the same way. Never show the question’s stored finding, or a number from it, as text. A finding was read once, by whoever created the question: its figures go stale as the data changes, and they can show a viewer figures their own data access would not return. A live chart runs with the viewer’s access and shows current values.

In App Builder, the starter’s src/kit.tsx Chart takes nextQuestions, each with the question’s name, its wording as title and a render() that returns its chart, such as another Chart. With no next questions it shows no light bulb. An app created before the starter had it keeps its own kit, so App Builder adds no next questions there and says why.

A headline figure with no breakdown needs no dimension. Mount the stored measure in a number object, or in a one-row table whose columns are all measures. Both narrow with the selections in their group, like any other object; see Selections on semantic layer items.

“Average order value” or “average line revenue” is a published measure computed per order or per order line, then averaged. Both steps run in the engine, so no new measure is needed. In a business question, put the grain on the measure selection; see Computing a measure at a finer grain. On a mounted object, set the same thing with three operations on the measure, after compiling a definition that binds the stored measure. Not every object type accepts them: check the type’s page in the operations reference before you choose the type.

const { dataItemInternalKey, dataItemUniqueSignature } = compilation.resolvedRefs.netRevenue;
const measure = { dataItemInternalKey, dataItemUniqueSignature };
const operationRequests = [
{
id: 'per-line',
name: 'setMeasureAdvancedCalculationType',
payload: { ...measure, advancedCalculationType: 'nestedCalculation' },
},
{
id: 'average',
name: 'setMeasureAdvancedAggregation',
payload: { ...measure, advancedOperationKey: 'advancedCalculation', aggregation: 'AVG' },
},
{
id: 'grain',
name: 'setMeasureAdvancedDimensionsIds',
payload: { ...measure, advancedOperationKey: 'advancedCalculation', dimensionsIds: [orderKey, productKey] },
},
];
  • dimensionsIds holds the field keys of the grain, looked up by name like any other field. Together they must pick out one row of the grain, here one order line. Order and product do so only when an order lists each product once; otherwise use the line’s own key. The grain fields need not appear in the object.
  • aggregation is how the per-grain values combine; AVG gives the average.
  • Send advancedOperationKey: 'advancedCalculation'.
  • Check the figure against an MCP query that selects the same measure with the same nested grain, as Verifying an app describes.

A KPI card’s change line can be a governed object:

  1. Store a question with the period dimension ordered descending and, for each headline measure, a second selection of the same measure with interRecord { comparison, offset: 1 }. Use growth for counts and amounts and diff for rates, so a rate changes in points.
  2. Mount a one-row table of the period and the change measure with queryLimit: 1. The window runs before the limit, so the first row still compares with the period before it.
  3. Show which period is compared, and label rates as a change in points. Colour by whether the direction is good for that measure, not by sign alone: rising expenses are bad news.

For month-on-month and quarter-on-quarter, store one question per period and mount the second set of change tables only when the reader first switches to it. Check whether the latest period is complete before comparing it; see the acceptance checks.

“This year against last year” and “the same period last year” are period comparisons, and the query engine computes them. Take the earlier period from a period-comparison measure in the layer: a measure that compares its value with the previous year or period on a Time Axis, shown as the earlier value, the change or the growth.

  • Over time. To plot both periods by month or week, make the measure’s Time Axis the object’s time dimension and bind the current measure beside the comparison measure. Each bucket is then compared with the same bucket a year earlier.
  • A single figure. Mount or query the comparison measure without a breakdown, as for headline figures, and name both periods as KPI card describes.

Do not build the earlier period from a second copy of the same measure with its own date filter, a measure filter or a second query over shifted dates. It is a second definition of the comparison, it can disagree with the layer’s, and a date filter the object cannot apply leaves the object showing every date with no error.

When the layer has no such measure, add one: a Time Axis on the date field, read as of the latest date in the data when the data stops before today, and a time intelligence measure on it; see Author through MCP. Objects read the published layer, so the comparison appears only once the layer is published.

Measure names in the layer are written for modellers, such as Avg Monthly Income; readers expect Income. Keep a display-name map in the app, keyed by stored name.

  • Tables: setColumnCustomLabelEnabled and setColumnCustomLabelValue on each column.
  • Charts: legends and tooltips show each item’s name from the layer. Neither the definition nor an operation renames a chart’s measures or dimensions, and writing a label into the vSpec is not supported. Where the chart type has them, give axes and the legend reader-facing titles in the definition’s presentation.axes and presentation.legend. When readers need a different name in legends and tooltips, ask the layer owner to rename the item.

Sliders that set a policy, such as a maximum debt-to-income, write numeric between selections; see Inputs. To keep every figure governed:

  • Put the objects that show the passing population in their own selection group. Write every threshold into it as a range on a stored per-row column, and mirror the page’s other filters into it.
  • To count the rows breaking each rule, give each rule its own group holding only that rule’s breach range, mirror the page’s other filters into it as well, and mount an Applications-style count in each. Without the mirrored filters, a breach count covers a different population from the passing count. One query per rule replaces any counting in the app.
  • Proportions such as “share passing” need a ratio measure or a second count beside the first; do not divide two query results in the app.

A page control that writes a selection, such as a scenario switch, moves every object in its group. A headline that must stay put, such as “savings of the recommended plan against doing nothing”, cannot be a plain sum in that group. Store a measure whose typed aggregate inputs each carry the filter for the slice they mean:

{
"expression": "{recommended} - {nothing}",
"inputs": [
{
"id": "recommended",
"kind": "aggregate",
"field": { "view": "Scenarios", "field": "Cost" },
"aggregation": "SUM",
"filter": {
"expression": "{scenario} AND {assumptions}",
"conditions": [
{
"id": "scenario",
"field": { "view": "Scenarios", "field": "Scenario" },
"operator": "equals",
"value": "A"
},
{
"id": "assumptions",
"field": { "view": "Scenarios", "field": "Assumption Set" },
"operator": "equals",
"value": "Base"
}
]
}
},
{
"id": "nothing",
"kind": "aggregate",
"field": { "view": "Scenarios", "field": "Cost" },
"aggregation": "SUM",
"filter": {
"expression": "{scenario} AND {assumptions}",
"conditions": [
{
"id": "scenario",
"field": { "view": "Scenarios", "field": "Scenario" },
"operator": "equals",
"value": "D"
},
{
"id": "assumptions",
"field": { "view": "Scenarios", "field": "Assumption Set" },
"operator": "equals",
"value": "Base"
}
]
}
}
]
}

The input filters define which scenario each side calculates. They do not exempt the measure from the object’s applied selections. Mount the headline in a separate selection group that omits the scenario control while mirroring the other intended filters, such as facility; otherwise an applied scenario selection can intersect an input filter and empty the result. Say in the card which slice it is pinned to.

A what-if that changes a rate, a capacity or a demand assumption is not app arithmetic. Compute the scenario rows in the warehouse, one row per base record, strategy and assumption set, in a long view with the strategy and the assumption set as columns. The page then switches between them with a selection on the assumption set, and compares strategies with the strategy as a dimension. Every chart, table and card re-queries from the stored rows, and the same scenario figures are available to anyone who queries the layer. Keep the headline cards that must not move pinned as above.

The abbreviationAuto, abbreviationNoDecimal, abbreviation1Decimal and abbreviation2Decimal format types pick k, M or B for each value by its size, so one column can show 41k beside 296M. For one fixed scale, use a custom format on the measure:

{ "formatType": "custom", "formatString": "#,##0.0,,\"M\"" }

Each comma after the last digit placeholder divides the value by 1,000:

formatString 296,281,123.4 shows as
#,##0, 296,281
#,##0,"K" 296,281K
#,##0,,"M" 296M
#,##0.0,,"M" 296.3M
  • Put the commas after the decimal places. #,##0,,.0"M" does not divide: it shows 296,281,123.4M.
  • Include a suffix or state the unit in the label, because #,##0, alone looks like an unscaled figure.
  • A fixed scale applies to every value: 41,250 shows as 0M under #,##0,,"M".

Checked in a bar chart, a number object and a table.

  • Define a measure in Business Context — the new formulas this page sends back to the layer are defined here, once, for every reader.
  • Publish your changes — a measure you add stays in your working copy until you publish; apps and dashboards carry on using the last published version.
  • Verifying an app — compares every figure that appears more than once and names the common causes when two of them disagree.