Configure semantic measures¶
measures.yaml lets you override the default aggregation datasight uses
for each measure and define calculated measures (like net_load_mw) that
behave like first-class columns. For the concept behind measures and how
they influence the AI, see
What semantic measures are.
Inspect what datasight inferred¶
CLI¶
This shows likely measures, their semantic roles, default and forbidden aggregations, weighted-average hints, suggested SQL rollup formulas, and configured display/chart metadata.
Web UI¶
- Load or explore a dataset.
- Use Key measures from the landing starter or the Inspect sidebar section.
- Review the inferred measure cards and SQL rollup guidance.
- Open Measure Overrides if you want to change measure behavior.
Create measures.yaml¶
measures.yaml lives in the project root. Datasight can create it for
you:
datasight generatedatasight measures --scaffold- saving an explore session as a project in the web UI
- saving from the web Measure Overrides editor
Override a physical measure¶
Use column when you want to override an existing physical column:
- table: generation_hourly
column: demand_mw
display_name: System demand
default_aggregation: max
format: mw
preferred_chart_types:
- line
reason: This project usually wants peak demand.
Define a calculated measure¶
Use name and expression for a measure that doesn't exist as a physical
column:
- table: generation_hourly
name: net_load_mw
expression: load_mw - renewable_generation_mw
display_name: Net load
default_aggregation: avg
format: mw
preferred_chart_types:
- line
- area
reason: Project-defined net load measure.
Weighted averages¶
For rates, prices, and similar non-additive measures, use weight_column
to prefer a weighted average over a plain AVG:
- table: emissions_hourly
column: co2_rate_lb_per_mwh
default_aggregation: avg
average_strategy: weighted_avg
weight_column: net_generation_mwh
format: float
That tells datasight to prefer rollups like:
Display metadata¶
display_name, format, and preferred_chart_types influence
deterministic measure overviews, trend recommendations, starter recipes,
and web measure editing flows. Examples:
display_name: Net generationformat: mwhpreferred_chart_types: [line, area]
Supported fields¶
Common fields in measures.yaml:
tablecolumn(for physical measures)name+expression(for calculated measures)roleunitdefault_aggregationaverage_strategyweight_columndisplay_nameformatpreferred_chart_typesallowed_aggregationsforbidden_aggregationsreason
Use the web editor¶
The Measure Overrides sidebar section in the web UI lets you edit
measures.yaml without leaving the app.
For a physical measure:
- Pick physical measure.
- Choose an inferred measure.
- Adjust aggregation, weighting, display name, format, or chart types.
- Save overrides.
For a calculated measure:
- Pick calculated measure.
- Choose the target table.
- Enter the measure name and SQL expression.
- Set aggregation, display name, format, and preferred chart types.
- Save overrides.
Datasight reloads semantic measure state after save, so the updated config immediately affects inspect flows, prompt guidance, and SQL validation.
Which file should you edit?¶
schema_description.md— narrative domain contextqueries.yaml— example questions and correct SQLmeasures.yaml— metric semantics and calculated measurestime_series.yaml— temporal structure and completeness expectations
Suggested workflow¶
- Start with
datasight measuresor Key measures. - Identify any wrong aggregation defaults.
- Add or edit entries in
measures.yaml. - Define calculated measures for project-specific business logic.
- Re-run Key measures, Trend ideas, or
datasight ask.
If a query still uses the wrong aggregation, check whether the user prompt explicitly asked for something like a total or average. Explicit user intent can override the configured default when that aggregation is allowed.