Skip to content

About

Independently verified: 165 KPI baselines checked by a separate test harness. Power BI EHS safety dashboard on synthetic data, with the semantic model authored as TMDL code and custom Deneb and HTML visuals.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

TerraFirm EHS Analytics

A five-page Environment, Health & Safety performance dashboard built in Power BI — model authored as code, every KPI independently verified, every visual custom-built.

TerraFirm Industrial Services is a fictional company. Every row of data is synthetic, produced by a deterministic generator in this repository. No client, employer, or real-world data of any kind is present.

Fully interactive, no sign-in required — hover the KPI cards to flip them, hover any chart for its tooltip, right-click a site to drill through.

Also published in the Microsoft Fabric Community Data Stories Gallery.

Overview page


What this is

Real EHS reporting balances leading indicators — the inspections, safety walks, behavioral observations, and training that prevent injuries — against lagging outcomes — the OSHA recordables, DART cases, and lost time that happen anyway. This report is a ground-up build of that platform, done the way a production model should be done:

  • Model as code. The entire semantic model is authored as TMDL text (Power BI Project format) — diffable, reviewable, version-controlled. A Python script scaffolds the whole PBIP from nothing.
  • Every number is verified. An independent test harness re-derives 165 KPI baselines from the raw CSVs across 11 filter scopes. If a DAX measure drifts from ground truth, the harness fails loudly.
  • Custom visuals throughout. Fourteen Deneb/Vega-Lite charts, hand-built HTML/CSS 3D flip cards, chart-specific report-page tooltips with their own mini-charts, and a dynamic HTML title bar — zero external image or script dependencies (all icons are embedded base64 SVGs).
  • One color policy. Every red/amber/green in the report grades against a target measure stored in the model: green beats the target with margin, amber sits inside a 10% warning band, red misses. No visual invents its own thresholds.
  • Zero dead weight. The model carries ~130 measures and every one is used by a page, tooltip, or another live measure — enforced by a Measure-Killer style audit script that walks the transitive DAX closure and prunes the rest.

The five pages

Page The question it answers
Overview Are we getting safer? R12 outcome trends (with prior-year ghost line) vs the site prevention league.
Leading Overview Why is the prevention score what it is? Weighted decomposition, weekly work volume, consistency heatmap.
Incidents What's hurting people, where, and are we hearing about it early? Pareto, severity mix, reporting pyramid.
Site Details One site's whole story — drill-through target from any site ranking.
Training Which courses slip, which sites lag, which people need attention?

Plus an in-report Info page — a rendered HTML guide explaining the color policy, interactions, data stories, and KPI definitions, with targets pulled live from the model.

Interactions: hover any KPI card and it flips to show quarterly detail or a plain-language definition; hover any chart for a custom tooltip page; right-click a site to drill through; Year/Region/Site slicers drive selection-aware trend lines (select a region and the chart shows that region's line in its legend color, not a mislabeled company line).

The tour

Leading Overview

Leading Overview — why the score is what it is. Every site's 0–100 score is a stacked bar of its four weighted components against the target line, so a mediocre total resolves into a specific deficit. The open tooltip is a report-page tooltip with its own Deneb chart: Northgate banks 25.0 of 30 training points but only 13.2 of 25 on weekly activity — the gap that keeps a best-in-class site off 80.

Incidents

Incidents — what's hurting people, and are we hearing about it early. The safety pyramid reads bottom-up: 639 near misses under 388 first aids under 106 recordables, each layer annotated with how far it sits below a healthy ratio. The pareto's tooltip breaks any category down by site — 140 chemical exposures, 30 of them at Ironwood. "Who speaks up" ranks near-miss ratio, where high is good: Fairhaven's 50+ against Halstead's 2.8.

Site Details

Site Details — one site's whole story. Right-click any site on any ranking to land here. Elmcrest shows the vacancy episode intact: TRIR of 3.48 against a 2.50 target and rising from 3.02, a weekly activity score of 16.8%, and 114 trainings past due. The trend chart puts the site's solid navy line against the company's dashed gray so the divergence is unmissable, and the at-risk observation mix names the behaviors — driving at 23%, procedures at 22%, both past the 20% line.

Info page

Info page — the report documents itself. A single HTML Content visual rendering a full styled document: the color policy, the interaction guide, the per-site data stories, and the KPI definitions. The target values in the text are pulled from the model's own target measures, so the documentation cannot drift from the thresholds the visuals actually use.

The data tells stories on purpose

Uniformly random data produces a dashboard that says nothing. Each site has a distinct safety personality, and scripted "episodes" recreate situations every EHS professional will recognize — so the visuals have something true to find:

Site Story What it teaches
Northgate Mature program, best outcomes, most near misses reported Strong reporting culture looks like more reports, not fewer
Ironwood Chronic underperformer — activity collapsed, incidents highest The league table floor
Lakeside Turnaround — period score still remembers the bad early months while the current trend is excellent The score remembers, the trend forgives: drill in
Elmcrest Supervisor vacancy (Jun–Aug 2025): activity collapses first, injuries follow on a two-month lag, both recover Leading indicators predict lagging outcomes — visible cause before effect
Granitebay Paper program: high activity volume, worst inspection quality, most at-risk behavior, near misses unreported Volume is not quality
Dunmore Audit-panic sawtooth: meets its weekly standard in 60% of quarter-end weeks, 8% of the rest Consistency beats bursts
Halstead A handful of recordables at a 50-person site produce the company's worst rate Never panic over one small site's TRIR — check the counts
Briarstone / Fairhaven Quiet mid-pack, including a zero-recordable site The model holds up beyond its hero

Seasonality is scripted too: slip/trip/fall incidents overweight December–February, so the category pareto shifts when you filter to winter.

Every claim above is re-verified against the CSVs in docs/STORY_AUDIT.md.

Architecture

flowchart TB
    D[DimDate] --> H[FactHours]
    D --> I[FactInspection]
    D --> O[FactObservation]
    D --> N[FactIncident]
    D --> T[FactTraining]
    D --> W[FactSiteWeek]
    S[DimSite] --> H & I & O & N & T & W
    P[DimPerson] --> I & O & T
    S --> P
Loading

Star schema, marked date table, no auto date/time, 15 single-direction relationships. FactHours carries month-grain exposure hours (the denominator for every OSHA rate); FactSiteWeek pre-computes the weekly activity standard deterministically so that logic lives in one tested place instead of a 40-line DAX measure. Partitions import only the columns the model uses.

KPI definitions

OSHA-standard formulas; 200,000 = the hours of 100 full-time workers per year.

KPI Definition
TRIR recordables × 200,000 / hours worked
DART rate (days-away + restricted cases) × 200,000 / hours
LTIR lost-time cases × 200,000 / hours
Near-miss ratio near misses / recordables — higher is better
Avg inspection score Σ points / Σ possible points (sum-over-sum, never an average of percentages)
Training compliance completed on or before due date / assigned
Weekly activity score site-weeks meeting the size-based standard / all site-weeks
Leading Indicator Score 100 × (0.30·training + 0.25·weekly activity + 0.25·inspection score + 0.20·(1 − at-risk share)) — weights are policy, stated on the report face

Rolling-12 variants are the trend lines to watch; year-to-date rates sawtooth every January.

Verification

py -3 scripts/verify_measures.py

re-derives all 165 baselines in VALIDATION.txt from the CSVs — overall, per-site, and per-year scopes — independently of both the generator's own validation pass and the DAX. Three-way agreement (generator, harness, model) is the definition of "correct" here.

The dataset also deliberately includes two classic modelling traps, and the harness proves the model dodges both: the date-only comparison trap (comparing raw datetimes misclassifies same-day training completions) and the averaged-percentage trap (averaging per-inspection percentages weights a 20-point checklist the same as a 30-point one).

Repository layout

EHSAnalytics.pbip            Power BI project entry point
EHSAnalytics.SemanticModel/  Model as TMDL (tables, measures, relationships)
EHSAnalytics.Report/         Report definition
data/                        Generated CSVs — 3 dims + 6 facts, ~36k rows
deneb/                       Vega-Lite spec + config per chart, named by chart title
scripts/                     Generator, model scaffolder, verification harness, patcher
docs/                        Data dictionary, story audit
assets/                      Page backgrounds, screenshots
VALIDATION.txt               165 KPI ground-truth baselines

Running it yourself

The fastest look is the live report — no install, no account. To open the project itself:

  1. Open EHSAnalytics.pbip in Power BI Desktop.
  2. If the repo isn't at C:\dev\EHS_Portfolio, update the pSourceFolder parameter (Transform data → Manage parameters) and refresh.
  3. Two free AppSource visuals are required: HTML Content (cards, titles, info page) and Deneb (all custom charts).

To regenerate the data from scratch (stdlib only, no dependencies — same seed → byte-identical CSVs):

py -3 scripts/generate_ehs_dataset.py
py -3 scripts/verify_measures.py

Deneb specs live in deneb/, one spec + config pair per chart, named after the chart's on-page title; deneb/README.md is the full build book.

License

Free to reuse. The data is synthetic and carries no third-party rights. TerraFirm Industrial Services is fictional; any resemblance to real organizations, sites, or people is coincidental.

About

Independently verified: 165 KPI baselines checked by a separate test harness. Power BI EHS safety dashboard on synthetic data, with the semantic model authored as TMDL code and custom Deneb and HTML visuals.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages