SQL Server to Databricks: Keep the Metric Definition — KCM guide artwork

KCM GUIDE / Databricks

SQL Server to Databricks: Keep the Metric Definition

Make the migrated report answer the same business question.

Moving every row does not guarantee that a KPI retains its meaning. This guide shows how to record the approved definition, test a three-job example, and make a clear go-or-hold decision before the first Databricks reporting release.

Read the full article

A reporting warehouse can move every row and still change a KPI. The source report counts completed service jobs. The new Databricks report counts labour entries. Both reports show the same ten hours, but one says three jobs and the other says five. A data reconciliation that checks only total hours will pass.

Before moving a decision-critical report, write down what each measure counts, which records qualify, when a record belongs in the period, and where the calculation runs. Then test those rules at the report surface that people actually use.

This guide continues KCM's SQL Server to Databricks migration series. Earlier articles cover workload selection, reporting procedures, historical assignments, and reader access. This one deals with the meaning of a reported number. It does not propose replacing an established semantic model just because the data platform changes.

Start with the report's question

“Jobs completed” sounds clear until a job has several labour entries. Consider three completed jobs in a service operation:

Job Labour entries Hours
J101 2 3
J102 1 4
J103 2 3
Total 5 10

The accepted source report shows 3 completed jobs, 10 labour hours, and 3.33 hours per completed job when rounded to two decimals. Counting rows in the labour table produces five “jobs” and two hours per “job”. The hours reconcile in both cases. The denominator does not.

SQL Server's COUNT(*) counts rows, while COUNT(DISTINCT job_id) counts unique, non-null job IDs. That distinction is documented behaviour, not a Databricks-specific migration issue. The migration risk comes from translating a business label without its grain and filters. Microsoft SQL Server COUNT documentation.

Find the definition people approved

Inspect the source report and its dependencies before choosing a target expression. The rule might live in a SQL Server view, stored procedure, Analysis Services or Power BI semantic model, or a combination. Power BI measures are expressions evaluated in report context; a visible number can therefore depend on the model as well as the database query. Microsoft Power BI measure guidance.

For each decision-critical measure, capture five facts:

  1. Name and owner. Who can approve a change to the business definition?
  2. Population. Does “completed” mean the final status, first completion event, or a separate approved milestone? What happens when a job reopens?
  3. Grain. Is one unit a job, a line, an event, or a customer? What identifier makes it unique?
  4. Period and grouping. Which date, time zone, and historical team or region assignment apply?
  5. Calculation and display. Where is the measure calculated, how are blank and zero handled, and when is it rounded?

The three-job example fixes only a narrow rule: count distinct, non-null job IDs in the approved completed-job population; sum accepted labour hours for those jobs; divide unrounded hours by the job count, then round the displayed average. A real release needs the source's actual status, time, and correction rules. Do not fill those in by assumption.

Choose one accountable calculation path

Moving data into Databricks does not require moving every measure out of Power BI. If the existing semantic model is accepted and remains the consumption layer, keep its measure logic unless there is a reason to change it. Test its relationships, filter context, and results against the new Databricks source.

If several consumers need the same definition, a centrally governed calculation may make sense. Unity Catalog metric views define reusable measures and dimensions; Databricks documents external BI access through custom SQL, a wrapper view, compatibility mode, or supported partner integration. Those patterns have different setup and limitations. Choose one only after checking the actual consuming tool and report behaviour. Azure Databricks metric views and external BI patterns.

A standard SQL view or curated table may be simpler for a fixed report. A Power BI DAX measure may be the correct owner for a report-specific calculation. Avoid defining “completed jobs” independently in both places and assuming the formulas will stay aligned. Record the authoritative definition and the person who approves changes.

Compare the result at more than one level

Build an acceptance fixture from approved source records, then run it through the source and target reporting paths. For the example, check job IDs J101–J103, the five labour entries, ten total hours, three distinct completed jobs, and the 10 ÷ 3 average before display rounding.

The exact job set matters. A matching grand total can hide a missing job offset by a duplicate or a changed filter. Compare a period boundary, one region or team split, a blank or unknown identifier, and a corrected or reopened job if those cases exist in the source. Keep expected results separate from observed results. A copied SQL expression is not acceptance evidence until the actual report returns the approved result.

Test the published report with a normal reader identity as well as the technical query. The earlier access guide covers the entitlement design; here the purpose is to confirm that filters and report context do not change the metric's meaning for that reader. If the definition is intentionally changing, label the new measure and obtain business approval. Do not quietly reuse the old name.

Make a go-or-hold decision

Approve the first release when the business owner can point to a recorded definition, the target report reproduces the approved fixture and representative slices, and the team knows which layer owns future changes. Hold if “completed job” still means different things in source and target, or if a passed total conceals a changed denominator.

The companion eGuide includes a metric contract, a small test fixture, and a report acceptance sheet. Bring one decision-critical report, its source definition, and the intended Databricks consumption path to KCM's Databricks consulting team.