Retain source rows
Invoice, order, receipt and reference records keep their original keys and load details.
SQL
For analysts and data teams working with operational tables that were designed to process orders, invoices and stock movements rather than answer management questions.
Quanta Meridian uses SQL to give each reporting table a clear grain, apply shared business rules once and retain the checks needed to explain a total.
How do invoice, order, receipt and reference records become one reporting result without changing their meaning?
See the finished examplesIn the wholesale reporting project, invoice lines, purchase orders and stock movements arrive in separate operational tables. SQL stages those records, assigns shared customer, product and date keys, and builds facts whose totals reconcile to the source. The same approach supports invoice matching, delivery measures and the retest of a corrected product mapping.
Invoice, order, receipt and reference records keep their original keys and load details.
Dates, identifiers and values are prepared once in named staging models.
Each fact states whether one row is an invoice line, order line, receipt or monthly balance.
Joins, exclusions and measures use the agreed business definition.
Counts and values tie back to source records, with exceptions retained for investigation.
Executed record lineage
The values below come from the retained Wide World Importers build. InvoiceLineID 1 keeps its source identity, enters a fact at declared grain, contributes once to January 2013 and reaches a recorded publish or hold outcome.
Sales.InvoiceLinesInvoiceLineID 1
conformed.fact_salesOne posted invoice line
mart.monthly_commercial_reportJanuary 2013
audit.validation_results18 of 18 checks passed
grain = one posted invoice line
key = invoice_line_id
value = SUM(fact_sales.net_sales_value)
group = month_startThe complete ordered SQL remains in the retained build; this compact contract shows the grain, key, value and grouping used by the graphic.
Named report checks
0 duplicate InvoiceLineID values
£0.00 residual; checked within one penny
9 of 9 cases detected
£0.00 residual; checked within one penny
A sales fact built at invoice-line level can answer product and customer questions without duplicating revenue. A delivery measure calculated at order level needs a different table and a clear rule for split or cancelled orders. Naming that grain first prevents a technically valid join from producing the wrong business total.
Shared dimensions then give Finance, Sales and Operations the same customer, product and date references. Transformations remain close enough to the source for an analyst to trace one record through the model.
The build keeps the executable SQL, schema, tests and results. Final checks compare row counts, key uniqueness and financial totals; reconciliation projects also keep the exact orders, receipts and invoices that do not agree.
A dashboard image cannot show that calculation. The useful detail is the query result, the failed rows and one source key followed through to the reported measure.
A finished example
From Wholesale Sales, Margin and Stock Reporting Mart. The saved result combines the actual query result with the decision to publish or hold the report. It shows what loaded, what the latest monthly mart contains and whether the checks allow publication.

Evidence type: executed analytical evidence
Where this is used
These examples use SQL at different grains: invoice line, purchase item, order, failed record and collision. Each link names the business question, SQL treatment and the check applied to the result.
Browse all 8 project examplesA wholesale company needs sales, purchasing, stock and margin reports to use the same customers, products, dates and totals.
SQL builds shared dimensions and invoice, purchase and stock facts from the Wide World Importers sample database.
Executed DuckDB results, source-to-report lineage and 18 passing report checks are available to inspect.
Accounts Payable should not clear a supplier invoice until the purchase order and warehouse receipt support it.
SQL compares ordered, received and invoiced quantities and values at purchase-item level.
The retained output shows supported items, payment holds and the team responsible for each difference.
An Accounts Payable reviewer needs to decide whether an invoice can proceed, must be held or should be returned to the supplier.
SQL compares the supplier invoice with the approved order and accepted warehouse receipts, then records the reason and reviewer responsible for every held case.
The retained DuckDB build reconciles 2,075 invoice cases and preserves the calculation, question, response, rematch and final decision for INV-000004.
Finance and Operations calculate on-time delivery differently when orders are split or partially delivered.
The approved delivery definition is implemented in SQL at order level and matched to the DAX and Excel versions.
Known delivery cases and one two-line split order prove how the denominator and completion date are assigned.
SQL, Power BI, Excel and the management pack publish different on-time-delivery percentages.
Independent SQL recalculations reproduce each treatment and bridge every result to the approved definition.
Row-level inputs, numerators, denominators and an exact numerical bridge are retained.
A missing product code removes a supplier category from the monthly report.
The retest query confirms that the corrected reference value restores the affected rows and total.
The issue history records the original failure, mapping change, second-analyst retest and whether the report was published or held.
A local road-safety team needs to decide which reported collision patterns merit a highways site inspection.
SQL joins final collision, vehicle and casualty records, calculates adjusted severe-casualty trends and orders one-kilometre review cells by visible criteria.
The full DfT population, validation results, inspection shortlist and one-collision trace are retained.
A cycle-hire service planner must prepare for short-term station demand, but completed journeys alone do not reveal bikes that customers wanted and could not hire. The planner needs a forecast, a visible range and a clear account of where the model performs poorly.
SQL supports the model, calculation or review route used to answer this decision: Which selected stations warrant an operational check before a planner changes a rebalancing or staffing plan?
A reproducible Python and DuckDB build across 356,057 journeys used in the study and 41,460 model-ready station-hours, with three forecast horizons, rolling-origin evaluation, fitted models and one station-day trace.
Working boundary
SQL can make a rule repeatable and a total traceable. It cannot decide the business meaning of an order, delivery or financial measure without the people responsible for that process. The cited build executes in DuckDB; the separate T-SQL deployment package is retained and linted, but remote SQL Server execution is not claimed.
Bring one disputed report total and the tables or extracts used to produce it. The first useful step is usually to state the grain and trace one record.
View the Analytics Engineering solutionDiscuss this capabilityReturn to all capabilities