SF logo
Power BI toolkit

KPI Measure Builder

Connect your model, describe the measures you need, copy the prompt into Copilot, then paste its answer back to get TMDL with correct tab indentation and your display folder applied.

Step1

Export your model from Power BI Desktop

One query lists every table, column, relationship and existing measure. It uses the built-in DAX query view, so no extra tools are needed.

  1. Open your report in Power BI Desktop.
  2. Select DAX query view on the left rail. It's the icon below Model view.
  3. Paste the query below into a new query tab and select Run.
  4. Above the results grid, select Copy. It copies every row with the column headers.
DAX query

      

Also works in the Power BI service: open the semantic model and choose Write DAX queries (needs write permission on the model). Auto date/time tables and row-number columns are dropped automatically.

Step2

Paste the query results

Paste straight from the Copy button. The summary below confirms what was read.

Measures that aren't in the export

In a composite model, measures that live in a remote semantic model may not show up in the export. List them here, one name per line, so Copilot can reuse them and the checks in Step 4 recognize them. Copy the names from the Data pane.

Step3

Describe the measures

One measure per line, in plain English. Mention the grain or filter if it matters, for example "excluding returns" or "for the selected fiscal year".

Copilot sees names, not data. It knows a column called [Segment] exists, not that its values are Consumer and Corporate. When a measure filters on specific values, name them in the request (“Sales for each customer Segment: Consumer, Corporate, Home Office”) or load them under Column values below.

Detailed measures

For measures a single line can't describe: ones that loop over rows (SUMX, MAXX), use a different date window for each row, or reach across several tables. The page works out how the tables connect and tells Copilot.

Column values (optional)

For measures that filter on specific values. List the columns, run the query in DAX query view, and paste the results. The values go into the prompt so Copilot can write one measure per value and spell them exactly.

Columns

Step4

Choose what Copilot sees and copy the prompt

Where the new measures go, and which tables the prompt describes. Fewer tables make a shorter prompt.

Where new measures go
Pick a table or folder from your model, type a new one, or clear the folder to put the measures at the top of the table.

Tables to include

Fewer tables means a shorter prompt. Keep every table your measures touch.

Prompt for Copilot

      

Paste the prompt into Copilot. It's asked to answer inside one code block, in labeled blocks that need no escaping. The prompt always ends with === END OF PROMPT ===; long existing formulas are shortened on purpose and marked [formula shortened]. If Copilot's input box doesn't show the end line after pasting, the prompt is too long: clear tables you don't need or turn off existing formulas.

Step5

Paste Copilot's reply and get TMDL

In Copilot, use the Copy button on the code block rather than selecting the text; selecting rendered text can add stray backslashes. Paste the whole reply here. Text around the code block is ignored, and JSON replies still work.