How do I find and remove the unused columns and measures of a semantic model with the CLI?
Run measurekiller-cli.exe service model with the workspace and the model name, or local analyze for a file open in Power BI Desktop, and save the unused objects with --out. Add --clean-tmdl to get the model without them: a TMDL folder for your Power BI project, a zip, or a TMDL script to paste into the TMDL view. Or ask your AI agent to do it.
Last updated · December 1, 2026
Steps
-
Find the model:
service workspaceslists the workspaces you can open,service itemslists what one workspace holds, with the IDs (details). -
Run
service modelwith--workspaceand--model, and save the result with--outand a full path. The file ending picks the format:.csv,.xlsxor.json. Add--unused-onlyto keep only what is unused (details). -
For a file that is open in Power BI Desktop, run
local models, thenlocal analyze. Pass the report files with--reportor--report-folder, otherwise everything that only a report uses shows as unused. -
Read the list named “Missing from the result” at the end of the run. A run can finish while some reports or models could not be loaded (details).
-
Add
--clean-tmdl PATHto get the model without what is unused. The PATH picks the form (details):- a folder: a TMDL folder, to use as the
definitionfolder of a Power BI project (.pbip) - a
.zipfile: the same folder, compressed - a
.tmdlfile: one script to paste into the TMDL view, in Power BI Desktop or in the browser, and apply
- a folder: a TMDL folder, to use as the
-
Review the clean model and apply it. The CLI never changes the model in your tenant. A removed source column also leaves the Power Query code, so a refresh does not load it again.
In the same run, --suggestions FILE saves the other suggestions of the app
that make the model smaller or simpler, --best-practices FILE the best
practice rule violations, and --broken-dax FILE the DAX in error.
Go deeper
Something wrong or out of date on this page?