# Report a quality scorecard

Shape / inspect

A variant of [Check data quality](https://meridian.online/operations/check-data-quality).

Run a set of rules and return one row per rule with its outcome, instead of stopping the run.

Page: <https://meridian.online/operations/check-data-quality/report-a-quality-scorecard>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

report one row per rule with its outcome instead of stopping the run

It reads the `orders` and `customers` tables the proofs share. Create them first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);

CREATE TABLE customers AS SELECT * FROM (VALUES
  ('Alice Ng',    'retail',    DATE '2025-06-01', 52.52, 13.40),
  ('Bob Okafor',  'wholesale', DATE '2025-09-15', 48.85,  2.35),
  ('Carla Diaz',  'retail',    DATE '2025-11-30', 40.42, -3.70),
  ('Frank Moore', 'retail',    DATE '2026-01-01', 51.51, -0.13)
) t(customer, segment, joined, lat, lon);
```

Then run the statement:

```sql
CREATE TEMP TABLE scorecard AS
SELECT rule, failing, checked, CASE WHEN failing <= allowed THEN 'pass' ELSE 'fail' END AS outcome
FROM (
  SELECT 'amount is present' AS rule, count(*) FILTER (WHERE amount IS NULL) AS failing, count(*) AS checked, 0 AS allowed FROM orders
  UNION ALL SELECT 'order_id is unique', count(*) - count(DISTINCT order_id), count(*), 0 FROM orders
  UNION ALL SELECT 'amount is positive', count(*) FILTER (WHERE amount <= 0), count(*), 0 FROM orders
  UNION ALL SELECT 'region is present (one gap allowed)', count(*) FILTER (WHERE region IS NULL), count(*), 1 FROM orders
  UNION ALL SELECT 'customer is a known customer', count(*) FILTER (WHERE c.customer IS NULL), count(*), 0 FROM orders o LEFT JOIN customers c USING (customer)
);
SELECT * FROM scorecard ORDER BY rule;
SELECT CASE WHEN ((SELECT count(*) FROM scorecard) = 5 AND (SELECT list((rule, failing, outcome) ORDER BY rule) FROM scorecard) = [('amount is positive', 0, 'pass'), ('amount is present', 1, 'fail'), ('customer is a known customer', 6, 'fail'), ('order_id is unique', 0, 'pass'), ('region is present (one gap allowed)', 1, 'pass')] AND (SELECT min(checked) FROM scorecard) = 10) THEN 'as expected' ELSE error('the scorecard should have five rows: two passes (positive amounts, unique ids), a pass for one allowed gap in region, and failures for the missing amount and the six unknown customers') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

- Duckle: [`Expectations`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/frontend/src/workflow-ui/palette-data.ts) (read 2026-09-25)
- AWS Glue: [`Evaluate Data Quality`](https://docs.aws.amazon.com/glue/latest/dg/data-quality-gs-studio.html) (read 2026-09-27)
- AWS Glue: [`EvaluateDataQuality`](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-transforms-EvaluateDataQuality.html) (read 2026-09-27)
- OpenRefine: [`Issue detection`](https://openrefine.org/docs/manual/wikibase/overview#issue-detection) (read 2026-09-27)
- Talend: [`tThresholdViolationAlert`](https://help.qlik.com/talend/en-US/components/8.0/reporting/reporting-component) (read 2026-09-27)
