add_template_measure
Add a measure to a table in a closed Power BI (.pbit) template by editing its model JSON on disk. Checks for name collisions and creates a .bak backup.
Instructions
Add a measure to a table in a closed .pbit template's model, editing the DataModelSchema JSON on disk with no Power BI Desktop. Collision-checked: fails if a measure of that name already exists on the table. The .pbit is written back in place (the original is copied to a .bak beside it first).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"pbitPath": "<pbitPath>",
"table": "<table>",
"name": "<name>",
"expression": "<expression>"
},
"name": "add_template_measure"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | measure name | |
| table | Yes | home table for the measure | |
| pbitPath | Yes | path to the closed .pbit template | |
| expression | Yes | DAX expression, e.g. SUM(Sales[Amount]) | |
| formatString | No | format string, e.g. "#,0" or "0.0%" (optional) | |
| displayFolder | No | display folder (optional) |