Case study · Retail BI governance

Semantic Model Metadata

A Power BI model that reads the metadata of every other model the BI team runs. One report shows which copies are stale, pointed at the wrong database, or drifting from each other.

33Model copies tracked across environments
204Metadata queries, one per copy and system view
11Automated checks on every refresh
17 / 16Tables / relationships in the model

The problem

Each semantic model had a copy per environment, each in its own workspace. Every copy carried its own server, database and refresh settings. Nothing showed in one place which copies were stale, read the wrong database, or no longer matched their PROD twin.

How the metadata gets in

  1. WorkspacesEach model copy, reached through the Power BI XMLA endpoint
  2. 7 system viewsTMSCHEMA tables, columns, measures, relationships, partitions, expressions, refresh policies
  3. Power QueryTags each row with model and environment, builds keys, appends the copies
  4. Semantic model17 tables, plus Snowflake lineage from ACCOUNT_USAGE
  5. Report7 pages, filtered by model and environment

Every row is tagged with its model and environment, so object IDs that repeat across models never collide. Code available to walk through in an interview.

The model

  • Workspace Info is the hub, with one row per model and environment. One slicer on it filters every page.
  • Relationships joins to separate From and To copies of Columns and Tables. Each relationship row can then compare its two ends' data types and storage modes.
  • Snowflake's OBJECT_DEPENDENCIES view maps each view a model reads to the tables behind it, and which roles can read it.
Power BI model view of the Semantic Model Metadata model, 17 tables. Workspace Info is the hub, joined to Workspace Parameters, Model Size GB, Model Last Refresh, Model Views and Relationships. Model Views joins Tables and Snowflake View Roles; Tables joins Columns and Tables Entity. Relationships joins From and To copies of Columns and Tables, each with its storage mode table.

The real model in Power BI Desktop's model view, all 17 tables. Select it to open full size; on a phone, scroll it sideways.

The 11 checks

CheckWhat it catchesModel fieldBuilt as
Data type matchA relationship joining two columns of different data typesRelationships[Data Type Match]Calculated column
Referential integrityA DirectQuery relationship with "Assume referential integrity" off, so Power BI sends outer joinsRelationships[Referential Integrity Check]Calculated column
Database per environmentA PROD copy reading the pre-prod database, or the reverseWorkspace Parameters[Database Name Issue]Calculated column
Server nameA copy pointed at the wrong Snowflake serverWorkspace Parameters[Server Name Issue]Calculated column
Stale refreshA last refresh older than that model's schedule allows, daily or weeklyModel Last Refresh[Last Refresh is Today]Calculated column
Duplicate column namesThe same column name in two tables of one model copyColumns[Column Name Duplicate Check]Calculated column
Sort-by columnA column sorted by a different column, listed for reviewColumns[SortByColumn Diff Column]Calculated column
Missing descriptionsShare of columns with no descriptionColumns[Description Blank %]Measure
Missing format stringsShare of columns with no format stringColumns[Format String Blank %]Measure
Snowflake database mismatchA view reading a table from a different databaseSnowflake Object Dependencies[Database Miss Match Count]Measure
Missing view roleA Snowflake view no role is granted to readSnowflake View Roles[SF View Role Blank or Not Blank]Calculated column

Two checks in DAX

Referential integrity on DirectQuery relationships

Referential Integrity Check =
SWITCH (
    TRUE (),
    Relationships[Referential Integrity] = "Off"
        && RELATED ( 'Storage Mode From Table'[Storage Mode] ) = "Direct",
        "Ref Should be Turned On",
    Relationships[Referential Integrity] = "Off"
        && RELATED ( 'Storage Mode To Table'[Storage Mode] ) = "Direct",
        "Ref Should be Turned On",
    ""
)

RELATED follows each relationship row to both of its ends, through the From and To table copies.

Duplicate column names within one model copy

Column Name Duplicate Check =
IF (
    CALCULATE (
        COUNTROWS ( 'Columns' ),
        ALLEXCEPT ( 'Columns', 'Columns'[Column Name], 'Columns'[Semantic Model Environment] )
    ) > 1,
    "Duplicate",
    "Unique"
)

ALLEXCEPT keeps only the name and the model copy, so the count spans every table in that copy.

The report

  • Model InfoRefresh status, size and issue count per copy
  • ConnectionsServer, database and warehouse per copy
  • PROD vs QADifferences between a model's copies
  • MeasuresEvery measure with its DAX
  • ColumnsType, format and description gaps
  • RelationshipsCardinality, direction and the checks above
  • Storage & RefreshStorage mode and incremental refresh per table

Before a release, the team picks a model and sees every copy's refresh, connection and drift on one page.