Power BI Best Practice Analyzer Results Viewer¶
Interactive HTML visualization tool for Tabular Editor's Best Practice Analyzer (BPA) results from TRX files.
Download Script View on GitHub
Live Demo¶
Try the interactive viewer with sample BPA results from multiple anonymized Power BI models:
- Switch between models using the dropdown (shows pass rates and timestamps)
- Filter results by All/Failed/Passed rules
- Expand categories to see rule details and violated objects
- Color-coded badges show severity levels (Error/Warning/Info)
- Statistics panel displays overall compliance metrics
The demo shows real BPA results (with scrubbed company data) so you can see exactly what the tool generates before running it on your own models.
Overview¶
This tool parses Visual Studio Test Results (TRX) files generated by Tabular Editor's BPA CLI and creates an interactive HTML dashboard showing rule violations, warnings, and pass rates across one or multiple Power BI semantic models.
Key Features:
- Multi-Model Results: Automatically discovers all TRX files, dropdown to switch between models instantly
- Interactive Filtering: Filter by severity (Error/Warning/Info), category, object type, or search
- Smart Visual Design: Color-coded severity badges, expandable details, real-time compliance stats
- Self-Contained Output: Single HTML file, works offline, shareable, CI/CD friendly
Prerequisites¶
- Python: 3.7 or higher
- Dependencies: None (uses Python standard library only)
- Input Format: TRX files generated by Tabular Editor CLI Best Practice Analyzer
How to Run¶
Step 1: Download the script¶
Save visualize_bpa_results.py anywhere in your repo (root folder, scripts/, tools/, wherever works for you).
Or download via command line:
curl -O https://raw.githubusercontent.com/JoeRossouw/semantic_ops/main/scripts/visualize_bpa_results.py
Step 2: Open a terminal¶
In VS Code: Terminal → New Terminal (or press Ctrl+`)
Step 3: Run it¶
The command is python followed by the path to the script. How you write that path depends on where you saved the script.
Option A: Drag and drop (easiest)
- Type
pythonin your terminal (with a space after) - Drag the script file from Explorer into the terminal
- Press Enter
The terminal pastes the full path for you.
Option B: Navigate to the script first
Option C: Ask GitHub Copilot
In VS Code with Copilot, just ask:
"Run the visualize_bpa_results.py script on my TRX files"
Copilot will figure out the correct path and run it for you.
The script will:
- Recursively search for all
.trxfiles - Parse BPA results from each file
- Generate
bpa_results_viewer.html - Open in your default browser
Advanced options¶
# Specify input directory (use with drag-and-drop or full path)
python visualize_bpa_results.py --input ./bpa_results
# Specify output location
python visualize_bpa_results.py --output ./reports/bpa_report.html
# Skip opening browser
python visualize_bpa_results.py --no-browser
# Combine options
python visualize_bpa_results.py -i ./test_results -o ./reports/report.html --no-browser
Command-line options:
| Option | Description | Default |
|---|---|---|
--input <path>, -i |
Directory containing TRX files (or path to single TRX file) | Current directory (recursive search) |
--output <path>, -o |
Output HTML file path | bpa_results_viewer.html in input directory |
--no-browser |
Skip automatically opening HTML in browser | Opens browser |
Input Requirements¶
This tool requires TRX files generated by Tabular Editor's Best Practice Analyzer CLI.
What you need: - TRX files (XML test results format) from Tabular Editor BPA runs - See Tabular Editor CLI documentation for how to generate TRX output
Once you have TRX files:
Expected Folder Structure¶
The script works with any folder structure containing TRX files:
your_project/
├── bpa_output/
│ ├── SalesModel_20241122_143022.trx
│ ├── FinanceModel_20241122_143045.trx
│ └── InventoryModel_20241122_143108.trx
├── SalesModel.SemanticModel/
├── FinanceModel.SemanticModel/
└── InventoryModel.SemanticModel/
The script recursively searches for any *.trx files regardless of folder depth.
Interactive Viewer Features¶
Visualization: - Model selector dropdown to switch between different BPA test runs - Pass rate progress bar showing compliance percentage - Severity badges: Info (blue), Warning (orange), Error (red) - Statistics panel with real-time counts (Total, Passed, Failed, by severity)
Controls: - Filter by All Rules / Failed Only - Expand All / Collapse All sections - Each rule shows name, severity, pass/fail status, expandable description - Click violation lists to see affected objects (measures, tables, columns)
Output: - Self-contained HTML file (200KB - 1MB depending on violations) - All data embedded as JSON, no external dependencies - Works offline, shareable with stakeholders
Troubleshooting¶
No TRX files found:
Solution: Run Tabular Editor CLI with BPA flags to generate TRX files, verify directory pathTRX parsing errors:
Common causes: Corrupted TRX, non-standard XML, empty results Solution: Re-run BPA analysisBrowser doesn't open:
Use --no-browser flag and manually open the HTML file
CI/CD Integration¶
GitHub Actions example:
- name: Run BPA Analysis
run: |
Get-ChildItem -Filter "*.SemanticModel" -Recurse | ForEach-Object {
TabularEditor3.exe $_.FullName -BPA -TRX "bpa_output/$($_.BaseName).trx"
}
- name: Generate Viewer
run: python visualize_bpa_results.py -i ./bpa_output -o report.html --no-browser
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: bpa-report
path: ./report.html
Azure DevOps example:
- task: PowerShell@2
inputs:
script: |
Get-ChildItem -Filter "*.SemanticModel" -Recurse | ForEach-Object {
TabularEditor3.exe $_.FullName -BPA -TRX "$(Build.ArtifactStagingDirectory)/bpa.trx"
}
- task: PythonScript@0
inputs:
scriptPath: 'visualize_bpa_results.py'
arguments: '--input $(Build.ArtifactStagingDirectory) --output report.html --no-browser'
Technical Details¶
- Parser: Python's
xml.etree.ElementTree - Input: Visual Studio Test Results (TRX) XML schema
- Browser: Modern browsers (Chrome, Firefox, Edge, Safari)
- Data: JSON-embedded in HTML for offline operation
- Filtering: Client-side JavaScript (no server required)
Related Resources¶
See Also¶
- visualize_all_relationships.py - Interactive relationship diagram generator for Power BI models
- rename_pbir_folders.py - Rename PBIR page/visual folders from GUIDs to readable names