pbi_generate_cleanup_script
Generates a reviewable Tabular Editor C# (.csx) cleanup script for unused columns and DAX measures, ordered leaf-first for safe dependency handling and defaulting to non-destructive hide actions.
Instructions
Generates a reviewable Tabular Editor 2/3 C# (.csx) cleanup script targeting unused columns and/or DAX measures in a semantic model, ordered leaf-first for safe dependency handling. Does NOT modify any Power BI model or file on disk; returns the .csx script text for human review. Defaults to safe non-destructive action='hide' rather than action='delete'. Refuses to emit mutation code when has_parsed_layouts is false. Use after auditing unused fields with pbi_find_unused_fields.
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": {
"model": "<model>"
},
"name": "pbi_generate_cleanup_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Semantic model name or dataset GUID. | |
| table | No | Optional table name filter. | |
| action | No | Remediation action: 'hide' (default, marks IsHidden=true and tags Description) or 'delete' (calls Delete()). | hide |
| workspace | No | Optional workspace name filter to disambiguate identically named models. | |
| field_type | No | Target object kind: 'all' (default), 'columns', or 'measures'. | all |
| exclude_fields | No | Optional deny-list of field refs ('Table[Field]' or bare names) to keep untouched. | |
| include_fields | No | Optional allow-list of field refs ('Table[Field]' or bare names) to include. | |
| dry_run_comment | No | When true, comments out all mutations and emits Info() preview logs only (default: false). |