A tool for managing Power BI Enhanced Report Format (PBIR) projects
Project description
PBIR Utilities
pbir-utils is a python project designed to streamline the tasks that Power BI developers typically handle manually in Power BI Desktop. This module offers a range of utility functions to efficiently manage and manipulate PBIR metadata.
Features
- CLI Support: Access all utilities directly from the command line.
- Extract Metadata: Retrieve key metadata informations from PBIR files.
- Update Metadata: Apply updates to metadata within PBIR files.
- Report Wireframe Visualizer: Visualize PBIR report wireframe.
- Disable Visual Interactions: Bulk disable interactions in PBIR report.
- Remove Measures: Bulk remove report-level measures.
- Get Measure Dependencies: Extract the dependency tree for report-level measures.
- Update Report Level Filters: Update the filters added to the Power BI report level filter pane.
- Sort Report Level Filters: Reorder filters in report filter pane on a specified sorting strategy.
- Standardize Folder Names: Standardize page and visual folder names to be descriptive.
- Sanitize Power BI Report: Clean up and optimize Power BI reports.
Installation
pip install pbir-utils
CLI Usage
The pbir-utils command is available after installation.
Tip: Use the
--summaryflag with any command to get concise count-based output instead of detailed messages.
1. Sanitize Report
Sanitize a Power BI report by removing unused or unwanted components.
pbir-utils sanitize "C:\Reports\MyReport.Report" --actions remove_unused_measures cleanup_invalid_bookmarks --dry-run
pbir-utils sanitize "C:\Reports\MyReport.Report" --actions all
pbir-utils sanitize "C:\Reports\MyReport.Report" --actions all --summary # Concise output
2. Extract Metadata
Export attribute metadata from PBIR to CSV.
pbir-utils extract-metadata "C:\Reports\MyReport.Report" "C:\Output\metadata.csv"
3. Visualize Wireframes
Display report wireframes using Dash and Plotly.
pbir-utils visualize "C:\Reports\MyReport.Report"
pbir-utils visualize "C:\Reports\MyReport.Report" --pages "Overview" "Detail"
4. Batch Update
Batch update attributes in PBIR project using a mapping CSV.
pbir-utils batch-update "C:\PBIR\Project" "C:\Mapping.csv" --dry-run
5. Disable Interactions
Disable visual interactions between visuals.
pbir-utils disable-interactions "C:\Reports\MyReport.Report" --dry-run
pbir-utils disable-interactions "C:\Reports\MyReport.Report" --pages "Overview" --source-visual-types slicer
6. Remove Measures
Remove report-level measures.
pbir-utils remove-measures "C:\Reports\MyReport.Report" --dry-run
pbir-utils remove-measures "C:\Reports\MyReport.Report" --measure-names "Measure1" "Measure2"
7. Measure Dependencies
Generate a dependency tree for measures.
pbir-utils measure-dependencies "C:\Reports\MyReport.Report"
8. Update Filters
Update report-level filters.
pbir-utils update-filters "C:\Reports" '[{"Table": "Sales", "Column": "Region", "Condition": "In", "Values": ["North", "South"]}]' --dry-run
9. Sort Filters
Sort report-level filter pane items.
pbir-utils sort-filters "C:\Reports" --sort-order Ascending --dry-run
pbir-utils sort-filters "C:\Reports" --sort-order Custom --custom-order "Region" "Date"
CI/CD Integration
The --error-on-change flag enables automated validation in CI/CD pipelines. When used with --dry-run, the CLI exits with code 1 if any changes would be made, allowing builds to fail automatically when reports don't meet standards.
Usage
# Fail if standardize-folder-names would make changes
pbir-utils standardize-folder-names "MyReport.Report" --dry-run --error-on-change
# For sanitize: specify which actions should trigger failure
pbir-utils sanitize "MyReport.Report" --actions all --dry-run --error-on-change set_first_page_as_active remove_empty_pages
Python API Usage
You can also use the library in your Python scripts:
import pbir_utils as pbir
# Example: Sanitize a report
pbir.sanitize_powerbi_report("C:\\Reports\\MyReport.Report", actions=["remove_unused_measures"])
To get started, refer to example_usage.ipynb notebook, which contains detailed examples demonstrating how to use the various functions available in pbir_utils.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pbir_utils-1.2.0.tar.gz.
File metadata
- Download URL: pbir_utils-1.2.0.tar.gz
- Upload date:
- Size: 62.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f8211c0280cf204f31443a92aa1f1501259a7e02b13e736e3a4ac7561e388e0
|
|
| MD5 |
b1cc89ceadf09ed5fcb0098a1ff3d418
|
|
| BLAKE2b-256 |
bbae867b6aa7203f36f0f6e4f3b8c1de4061a385870c2d35fcac1675eaf024a3
|
File details
Details for the file pbir_utils-1.2.0-py3-none-any.whl.
File metadata
- Download URL: pbir_utils-1.2.0-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b6ea6def6b23dce70dec77f8ee6a75bfbc6efcd90af6941150e228546182608
|
|
| MD5 |
8b7fb29449cfe8ffb35ac3579629d3e2
|
|
| BLAKE2b-256 |
86f6a43ce9eff7b81b9fd19bcc919c11d1f9554cbaaac4c7b90765281fb753e9
|