Skip to content

marcelodfelman/DaxDependencyMeasureChecker

Repository files navigation

TMDL Measure Dependencies Visualizer

An interactive web-based tool for visualizing measure dependencies in Power BI TMDL (Tabular Model Definition Language) files.

🎯 Features

  • Interactive Graph Visualization: View all measures and their dependencies as a directed graph
  • Hierarchical Layout: Automatic layout showing the flow of dependencies
  • Measure Details: Click on any measure to view:
    • DAX formula
    • Format string
    • Display folder
    • Dependencies list
  • Search & Filter:
    • Search measures by name
    • Filter by table
  • Highlighting: Double-click a measure to highlight all its dependencies
  • Export: Export the diagram as PNG image
  • Responsive Design: Modern, clean interface with smooth animations

📁 Project Structure

Sales Dashboard.SemanticModel/
├── definition/
│   └── tables/          # TMDL table files with measure definitions
│       ├── Fact_Sales.tmdl
│       ├── Dim_Dates.tmdl
│       ├── tbl_Measures.tmdl
│       └── ...
├── tmdl_parser.py       # Python script to parse TMDL files
├── measures_data.json   # Generated JSON with measures and dependencies
├── index.html           # Main web interface
├── measure_visualizer.js # JavaScript for graph visualization
└── README.md           # This file

🚀 Getting Started

Prerequisites

  • Python 3.6 or higher
  • A modern web browser (Chrome, Firefox, Edge, Safari)

Step 1: Parse TMDL Files

Run the Python parser to extract measures and analyze dependencies:

cd "c:\Users\marce\Downloads\PBIP File\Sales Dashboard.SemanticModel"
python tmdl_parser.py

This will:

  1. Scan all .tmdl files in definition/tables/
  2. Extract measure definitions
  3. Analyze DAX formulas to find dependencies
  4. Generate measures_data.json

Step 2: Open the Web Interface

Open index.html in your web browser:

# On Windows
start index.html

# Or simply double-click index.html in File Explorer

The visualizer will automatically load the data from measures_data.json.

🎨 How to Use

Basic Navigation

  • Pan: Click and drag on the background
  • Zoom: Use mouse wheel or navigation buttons
  • Select Measure: Click on any node
  • Highlight Dependencies: Double-click on a measure node

Controls

  1. Search: Type a measure name to quickly find and focus on it
  2. Table Filter: Filter measures by their parent table
  3. Reset View: Clear all selections and show all measures
  4. Fit to Screen: Adjust zoom to show all visible measures
  5. Export PNG: Download the current view as an image

Understanding the Visualization

Colors

  • Blue nodes: Regular measures
  • Red node: Currently selected measure
  • Green nodes: Dependencies of the selected measure

Arrows

  • Arrows point from a measure to the measures it depends on
  • The direction shows the dependency flow

Example Workflow

  1. Open the tool in your browser
  2. Use the search box to find "Total Sales"
  3. Click on the measure to see its details
  4. Double-click to highlight all its dependencies
  5. Click on a dependency in the sidebar to navigate to it
  6. Export the diagram if needed

📊 TMDL File Structure

The parser understands the following TMDL measure structure:

table TableName
    measure 'Measure Name' =
        DAX_FORMULA
    formatString: #,0
    displayFolder: 2-Measures\Sales
    lineageTag: unique-id

Measure Properties Extracted

  • name: The measure name
  • table: Parent table name
  • formula: Complete DAX formula
  • formatString: Number/date formatting
  • displayFolder: Organizational folder path
  • lineageTag: Unique identifier
  • dependencies: List of other measures referenced

🔍 Dependency Detection

The parser identifies dependencies by:

  1. Scanning DAX formulas for measure references: [MeasureName]
  2. Matching references against known measures
  3. Building a directed graph of dependencies

Example

measure 'Sales Full LY' =
    VAR _MinDate = [MinDate LY]
    VAR _MaxDate = [MaxDate LY]
    RETURN
        CALCULATE(
            [Total Sales],
            FILTER(...)
        )

Dependencies detected: MinDate LY, MaxDate LY, Total Sales

🛠️ Customization

Modifying the Parser

Edit tmdl_parser.py to:

  • Add support for additional measure properties
  • Customize dependency detection logic
  • Change output format

Styling the Visualizer

Edit the <style> section in index.html to:

  • Change color scheme
  • Adjust layout parameters
  • Modify fonts and spacing

Graph Options

Edit measure_visualizer.js to customize:

  • Layout algorithm (hierarchical, force-directed, etc.)
  • Node shapes and sizes
  • Edge styles
  • Interaction behaviors

📈 Statistics

Current model contains:

  • 56 measures across 8 tables
  • 27 measures have dependencies
  • Maximum dependencies per measure: 3

Tables with Measures

  • Fact_Sales: 27 measures
  • Dim_Dates: 8 measures
  • Dim_Agents: 6 measures
  • Dim_Products: 4 measures
  • Dim_Customers: 3 measures
  • Parameter_SalesAndProfit: 3 measures
  • factBikesSales: 3 measures
  • tbl_Measures: 2 measures

🐛 Troubleshooting

Issue: Graph doesn't load

Solution:

  • Ensure measures_data.json exists
  • Check browser console for errors
  • Verify you're opening via HTTP (not file://) or use a local server

Issue: Dependencies not detected

Solution:

  • Check if measure references use square brackets: [MeasureName]
  • Verify measure names match exactly (case-sensitive)
  • Run the parser again to regenerate data

Issue: Cannot run Python script

Solution:

  • Verify Python is installed: python --version
  • Ensure you're in the correct directory
  • Check file paths in the script

🔄 Updating Data

When your TMDL files change:

  1. Re-run the parser:

    python tmdl_parser.py
  2. Refresh the browser (F5) to reload the visualization

📝 Technical Details

Technologies Used

  • Backend: Python 3 with standard libraries
  • Frontend: Vanilla JavaScript (ES6+)
  • Visualization: vis.js network library
  • Styling: Modern CSS with gradients and animations

Browser Compatibility

  • Chrome/Edge: ✅ Full support
  • Firefox: ✅ Full support
  • Safari: ✅ Full support
  • IE11: ❌ Not supported

💡 Tips

  1. Performance: For models with 100+ measures, filtering by table helps
  2. Navigation: Use keyboard shortcuts (arrow keys) to navigate
  3. Export: Export before making changes for documentation
  4. Analysis: Look for measures with many dependencies - they might be good candidates for optimization

📄 License

This tool is provided as-is for analyzing TMDL files. Modify and use as needed.

🤝 Contributing

To extend this tool:

  1. Fork or copy the project
  2. Make your modifications
  3. Test with your TMDL files
  4. Share improvements!

📞 Support

For issues or questions:

  • Check the console for JavaScript errors
  • Verify TMDL file format matches expectations
  • Review the parser output for warnings

Happy visualizing! 📊✨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors