Uncategorized

Build Data Quality Checks Before Publishing a BI Report

Star-schema diagram with one central fact table linked to four surrounding dimension tables.

Quick answer: Validate the data before making a BI report available to readers. Check required fields, business-key uniqueness, valid values, matching reference records and reconciled totals. Define which failures block publication, retain exception details, and rerun the checks after corrections. Treat manual review as a separate approval step—not a replacement for automated validation.

This guide is for analysts, finance and operations managers, and BI developers preparing an order report. The worked example uses synthetic records and SQL Server/Azure SQL syntax. The validation approach can be adapted to other platforms, but the SQL is not portable without changes.

1. Define what a trustworthy report must contain

Before writing checks, document the report’s data contract: the conditions its input must satisfy.

For an order report, specify:

  • Grain: one row per order, or one row per order line?
  • Business key: OrderID, or a combination such as OrderID and LineNumber?
  • Required fields: which values must be present?
  • Reporting scope: which dates, statuses, business units and currencies are included?
  • Metric definition: what does “order amount” include or exclude?
  • Cutoff: which source snapshot or extraction batch should the report represent?
  • Responsibility: who investigates failures and approves exceptions?

For this example, the contract is one row per order, covering February 2026, in USD. Order ID, customer ID, order date and amount are required. Amounts must be nonnegative because this particular dataset excludes refunds.

That last rule is an example policy, not a universal business rule. A dataset that includes refunds needs a different amount check.

Write the contract first so that every failure has a clear explanation. “Duplicate order key” is actionable only when the agreed grain is one row per order.

2. Turn the contract into explicit validation rules

Use the following checks as a starting specification. Adapt them to the report rather than copying thresholds blindly.

Check Question to answer Example rule
Completeness Are required values present? No missing customer IDs
Uniqueness Does each business key occur at the intended grain? One row per OrderID
Valid values Do values satisfy type and business rules? Dates parse successfully; amounts are nonnegative
Referential integrity Does each reference identify an allowed record? Every non-null customer ID exists in the customer table
Reconciliation Do counts and amounts match an independent control? Order count and amount match the agreed source snapshot
Freshness and coverage Is the expected reporting batch complete? Required batch has arrived and passed validation

SQL Server supports primary keys, unique constraints, foreign keys and check constraints for enforcing different aspects of integrity. A primary key requires non-null, unique key values; foreign keys enforce links to referenced records. These are useful protections where you control the database schema. (learn.microsoft.com)

However, do not assume a value-range constraint also makes a field mandatory. In SQL Server, a CHECK constraint can allow NULL because the expression evaluates to unknown rather than false. Required fields need explicit completeness enforcement, such as NOT NULL, as well as appropriate value rules. (learn.microsoft.com)

For each rule, record its identifier, scope, failure count, threshold, severity and owner. Keep example failing records in a restricted exception table so the responsible team can investigate.

Diagram of a star schema showing a central fact table connected to surrounding dimension tables.
A star-schema illustration. Validate reference keys before using relationships to enrich report data. — SqlPac. Own work Source CC BY-SA 3.0

3. Work through a deliberately flawed order batch

The following data is entirely synthetic. Row identifies an incoming record, not the business key.

Row OrderID CustomerID OrderDateText AmountUSD
1 1001 101 2026-02-25 100.00
2 1001 101 2026-02-25 100.00
3 1002 Missing 2026-02-26 75.00
4 1003 103 2026-02-30 50.00
5 1004 104 2026-02-27 80.00
6 1005 999 2026-02-28 60.00

Assume the synthetic customer reference table contains IDs 101, 102, 103 and 104.

Expected failures are:

  • Completeness: row 3 has no customer ID.
  • Uniqueness: order 1001 appears twice. That is one duplicate key group, two affected records and one excess record.
  • Valid date: row 4 contains an impossible calendar date.
  • Referential integrity: customer 999 in row 6 has no matching reference record.
  • Reconciliation: the incoming batch contains six rows totaling $465.00, while the example’s independent control expects five orders totaling $365.00.

These counts describe different problems. Do not add them together and call the result “bad rows”; checks can overlap.

For this exercise, the intended corrections are explicitly supplied: remove the repeated row 2, set order 1002’s customer to 102, correct order 1003’s date to February 28, 2026, and set order 1005’s customer to 104.

After those corrections, the batch contains five unique orders totaling $365.00, and the listed row-level checks return zero failures.

In production, verify corrections against authoritative records. Do not guess a customer from nearby rows or replace an invalid date with the refresh date.

4. Automate checks and use profiling for investigation

Here is a self-contained SQL Server/Azure SQL demonstration. Run both code blocks in the same batch if you want to reproduce the example.

TRY_CONVERT returns NULL when a permitted conversion cannot parse the input; explicitly prohibited conversions can still raise an error. The date check uses style 23, documented as yyyy-mm-dd. It tests conversion validity, not an exact text-format contract. (learn.microsoft.com)

DECLARE @Orders TABLE (
    RowID int,
    OrderID int,
    CustomerID int,
    OrderDateText varchar(20),
    AmountUSD decimal(12,2)
);

INSERT INTO @Orders VALUES
(1, 1001, 101,  '2026-02-25', 100.00),
(2, 1001, 101,  '2026-02-25', 100.00),
(3, 1002, NULL, '2026-02-26',  75.00),
(4, 1003, 103,  '2026-02-30',  50.00),
(5, 1004, 104,  '2026-02-27',  80.00),
(6, 1005, 999,  '2026-02-28',  60.00);

DECLARE @Customers TABLE (
    CustomerID int PRIMARY KEY
);

INSERT INTO @Customers VALUES (101), (102), (103), (104);

SELECT 'Missing required values' AS CheckName,
       COUNT(*) AS FailureCount
FROM @Orders
WHERE OrderID IS NULL
   OR CustomerID IS NULL
   OR NULLIF(LTRIM(RTRIM(OrderDateText)), '') IS NULL
   OR AmountUSD IS NULL

UNION ALL

SELECT 'Duplicate excess records',
       COALESCE(SUM(KeyCount - 1), 0)
FROM (
    SELECT COUNT(*) AS KeyCount
    FROM @Orders
    GROUP BY OrderID
    HAVING COUNT(*) > 1
) AS Duplicates

UNION ALL

SELECT 'Invalid or missing dates', COUNT(*)
FROM @Orders
WHERE TRY_CONVERT(
    date,
    NULLIF(LTRIM(RTRIM(OrderDateText)), ''),
    23
) IS NULL

UNION ALL

SELECT 'Unmatched non-null customer IDs', COUNT(*)
FROM @Orders AS o
WHERE o.CustomerID IS NOT NULL
  AND NOT EXISTS (
      SELECT 1
      FROM @Customers AS c
      WHERE c.CustomerID = o.CustomerID
  )

UNION ALL

SELECT 'Invalid amounts', COUNT(*)
FROM @Orders
WHERE AmountUSD < 0;

Expected failure counts are 1, 1, 1, 1 and 0, respectively. Missing amounts are handled by the completeness check. Missing dates can fail both completeness and date validation.

Then inspect the batch controls:

SELECT
    COUNT(*) AS IncomingRows,
    COUNT(DISTINCT OrderID) AS DistinctOrders,
    SUM(AmountUSD) AS TotalAmountUSD
FROM @Orders;

Expected results are 6 incoming rows, 5 distinct orders and $465.00. Counting distinct orders alone would conceal the repeated amount.

If you use Power Query, enable Column quality, Column distribution and Column profile in the editor’s View tab. Profiling defaults to the first 1,000 rows; switch it to the entire dataset before treating the profile as a full-data inspection. (learn.microsoft.com)

Use profiling to investigate patterns. Keep scheduled rule execution and its recorded results as the publication control; a person inspecting preview indicators is a manual review activity.

5. Reconcile totals on the same reporting basis

For reconciliation, compare the report’s candidate data with an independently produced control—not another calculation over the same possibly flawed extract.

First align:

  1. Source snapshot or batch identifier.
  2. Reporting period and cutoff.
  3. Included order statuses.
  4. Currency and conversion rules.
  5. Treatment of refunds, cancellations, tax and shipping.
  6. Amount precision and rounding policy.

For the synthetic example:

Control Incoming batch Corrected batch Expected
Record count 6 5 5
Distinct orders 5 5 5
AmountUSD 465.00 365.00 365.00

The original amount difference is +$100.00. Removing the confirmed duplicate explains that difference. Correcting the customer IDs and date does not change the amount.

Also compare counts and amounts before and after each intended many-to-one join. A join against a reference table with repeated keys can multiply records; an inner join can exclude unmatched records. These are consequences of the join logic, so validate the output even when the input passed its checks.

For a simple order-to-customer enrichment, require customer-key uniqueness and explain any change in order count or total amount.

6. Create a publication gate that blocks on uncertainty

A check query produces evidence. It does not, by itself, prevent publication.

Design the workflow so that validation runs against a fixed candidate batch, and only an approved batch becomes available to the report. For imported models, validate before refreshing the production model. For live-query designs, consider a validated serving layer rather than letting the report read unchecked staging data.

A practical gate is:

Stage → validate → reconcile → review → approve → expose to readers.

Use separate outcomes:

Outcome Example policy Action
Block Any duplicate order key, invalid required date or unexplained reconciliation difference Do not release the candidate
Warn Missing optional descriptive values within an approved tolerance Record the issue and obtain required approval
Pass All required checks completed within their limits Proceed to review or release

These are proposed policies, not industry-standard thresholds. For this example, the critical checks have a zero-failure threshold. Any nonzero tolerance should have an owner, rationale and defined denominator.

Treat a check that did not run as unknown, not pass. Likewise, an unexpectedly empty batch needs investigation rather than automatic approval because it contains no invalid rows.

Record the batch ID, rule version, execution time, checked population, observed result, threshold and decision. Tie approval to that exact batch so later source changes cannot silently replace the validated data.

Diagram illustrating an open data-quality cleansing and monitoring pattern.
A data-quality cleansing and monitoring pattern. Keep validation results connected to corrective action and release decisions. — Dewald Jacobs. Own work Source CC BY-SA 3.0

7. Finish with manual review and a reusable checklist

Automated checks assess the rules you defined. Manual review should assess whether those rules and the resulting report answer the business question.

Before release, ask a business owner to confirm the metric definitions, compare key totals with the agreed control, inspect representative orders and review the exceptions. Check that report filters and period labels match the validated scope.

Avoid these common shortcuts:

  • Deleting duplicates immediately: investigate whether they are repeated orders or legitimate order lines.
  • Replacing errors with defaults: preserve the original value and document the correction.
  • Accepting a matching grand total: check important business-unit or period subtotals for offsetting differences.
  • Treating successful loading as approval: require explicit validation results.
  • Checking only incoming data: rerun relevant checks after transformations and joins.

Use this release checklist:

  • Grain, business key, scope and metric definitions are documented.
  • Required fields have explicit missing-value checks.
  • Duplicate counts distinguish groups, affected records and excess records.
  • Dates and business values satisfy agreed rules.
  • Reference keys match the correct reference snapshot.
  • Counts and amounts reconcile on the same basis.
  • Post-transformation and post-join results are checked.
  • Every required check completed; no unknown result is treated as pass.
  • Exceptions have owners and documented decisions.
  • The approved batch—not an unchecked replacement—is released.

Start with a small set of critical checks that can actually stop a bad release. Expand the rule set as you discover additional failure modes.