Write DataPrism measures with AI

DataPrism's measure editor has an AI that writes a measure's expression for you: from a description you type, from the measure's name alone, or as a repair when a save fails. The editor's controls live on Measure editor; this page covers how the AI works and what its expression must obey.

Write a measure from a description

  1. In the measure editor, open the AI measure popover: click the AI measure control in the editor header, or press Ctrl+Shift+M.
  2. Describe the measure in the box, for example Revenue share of each region within its year..., and click Generate.
  3. Review the expression it writes into the editor, then save the measure.

The AI replaces the editor's content in one change, and nothing is saved until you save. If it has something to flag, it arrives as a note in the AI notes toast.

Write a measure from its name

With a name in the Measure name field, press Ctrl+Enter there, or click the control beside the field (its tooltip reads Generate expression from the measure name (Ctrl+Enter)). The request carries just the name, so the AI builds what the name says, following the way Power BI authors name measures: a measure named Revenue YoY % is written as growth over the previous year.

Repair a failed save

When a save is refused, the banner above the editor carries the reason. Click Fix with AI: the AI receives the expression that failed and the error it hit, and writes one minimal correction that keeps your intent, the same aggregates, constants, rounding and structure.

What the expression must obey

When a save is refused

Every save runs the platform's checks first: the expression is probed in the shape a chart will run it in, over no rows, and it must produce exactly one value of a chartable type. When a check fails, the save is refused and the message begins measure validation failed:; the text after the colon tells you which check spoke.

Open the message's full text from the banner before you fix it, or let Fix with AI make its one repair pass.

Windowed measures on charts

Time intelligence, running totals, shares and ranks come from windows inside the measure. The AI writes them with PARTITION BY ALL, a DataMind macro the chart expands at run time to the chart's group-by columns minus the window's order columns:

sql
lagInFrame(sum("Revenue"), 1, 0) OVER (PARTITION BY ALL ORDER BY "Year")

Grouped by year, that expression compares each year with the previous one; add another grouping to the chart and the comparison stays within each value of it, so one measure fits many charts.

Questions, answered

What does the AI see when it writes my measure?

The model's tables and columns with their types, and the model's other measures. It reads no rows of your data; it writes the expression, and the expression meets the data only when a chart runs it.

Why does the AI build on other measures instead of writing the maths again?

Because the model already defines those pieces, and building on them keeps every result consistent: a later fix to the base measure flows into the measures that use it. It writes the raw aggregation only where reuse would not work.

What happens if the model cannot express what I asked for?

The AI writes the closest valid measure it can and explains the gap in its notes. It never invents a column to satisfy the request.

Why does the AI wrap a denominator in nullIf(..., 0)?

So division by zero reads as an empty value instead of an error. Every denominator is guarded this way, for example sum("Revenue") / nullIf(sum("Orders"), 0).

Why did my save fail with measure validation failed:?

The platform's checks refused the expression, and the text after the colon names the reason: a forbidden pattern (the expression is not allowed: with the sentences for each problem), the database's own error, or a failed check. Correct the expression and save again, or let Fix with AI do one repair pass.

Why does a chart say my measure requires group-by columns?

The measure uses a window, and the window's columns are not among the chart's group-by fields. The refusal names the missing columns: add them to the chart, or use the measure on a chart that already groups by them.

What is PARTITION BY ALL?

A DataMind macro. The chart expands it at run time to the chart's group-by columns minus the window's order columns, and to a single partition when nothing is left. That is what lets one previous-period or running-total measure fit many chart groupings without changes.

Is the expression saved automatically?

No. The AI writes into the measure editor as an unsaved change; nothing reaches the model until you save the measure. A repair works the same way: review it, then save.

Can the AI change other measures or the model itself?

No. It writes the one expression for the measure you have open and reads the rest of the model only to build on it. To change columns, relationships or other measures, use the Model AI chat.