PowerBIAnalyzer is a script that helps to identify unused fields (columns, calculated columns, or measures) in Power BI files. It works on Power BI Template (.pbit) files.
- Save your Power BI report as a template in .pbit extension
- Download the PowerShell or Python script
- Open a terminal and navigate to the directory where the script is located.
- Run the script using the following command:
Replace "path_to_pbit_file" with the actual path to your Power BI file.
powershell .\PowerBIAnalyzer.ps1 -TemplatePath "path_to_pbit_file"
- Run the script using the following command:
python .\PowerBIAnalyzer.py "path_to_pbit_file"
The PowerBIAnalyzer script performs the following steps:
- Takes the input .pbit file, extracts it to a remporary location under the user's
%home%
directory (.pbit files are just .zip files with a different extension), reads the contents of the relevant files inside (DataModelSchema and Report\Layout), then deletes all the temporary content - Extracts all the columns, calculated columns, and measures from DataModelSchema
- Checks all fields one by one against the relevant contents of Layout to identify fields which are directly referenced (as inputs, formatting for visuals, or filters)
- Recursively checks all the unused fields if they are used in DAX expressions anywhere in the used fields
- Prints out all the field references that are not used anywhere
- PowerShell 5.1 or later
- Python 3.6 or later
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
This script is provided as-is without any warranty. Use it at your own risk.