@tables

Arithmetic checks over table columns: totals, equations, return chains, percentages.

Mission control: These systems are still on the test stand. Fly them, log everything.

Under review: works today, may fold into expressions or a vocabulary before 1.0.

Quick reference

Examples

@tables/total

Check a table's totals: each numeric data column must sum to its declared Total row within tolerance. Skips columns with any unparseable cell; silent when there is no Total row. Warns only. Parameterised by @tables/total=<column>, .totalLabel= and .tolerance=.

<!-- mdv: section -->
## Status
<!-- mdv: table @tables/total -->
| Line     | Amount |
| -------- | ------ |
| Product  | 8,000  |
| Services | 2,000  |
| Total    | 10,000 |
<!-- mdv: endtable -->
<!-- mdv: endsection -->

@tables/total.totalLabel

Parameter of @tables/total: the total row becomes the LAST row whose first cell contains this label as a whole word, ignoring case. Rows matching the label are excluded from the summed parts. Quote labels with spaces (either quote style; ", ' and \ escape). An empty value, or malformed quoting, reports invalid-option.

<!-- mdv: section -->
## Status
<!-- mdv: table @tables/total @tables/total.totalLabel="Grand Total" -->
| Line     | Amount |
| -------- | ------ |
| Product  | 8,000  |
| Services | 2,000  |
| Grand Total | 10,000 |
<!-- mdv: endtable -->
<!-- mdv: endsection -->

@tables/total.tolerance

Parameter of @tables/total: an explicit absolute tolerance (a number ≥ 0, in the column's unit) replacing the auto-derived 0.5×10^-P×(cells+1); 0 = exact, up to a 1e-9 floating-point guard. A malformed value reports invalid-option.

<!-- mdv: section -->
## Status
<!-- mdv: table @tables/total @tables/total.tolerance=0 -->
| Line     | Amount |
| -------- | ------ |
| Product  | 8,000  |
| Services | 2,000  |
| Total    | 10,000 |
<!-- mdv: endtable -->
<!-- mdv: endsection -->

@tables/equation

A target column must equal a ±-expression of other columns per row (unit=raw|pct|bps, tol=<n>). Skips rows with blank/unparseable cells; reports invalid-option for a named column the table lacks. Warns only.

<!-- mdv: section -->
## Status
<!-- mdv: table @tables/equation=End=Begin+Flows+PnL -->
| Period | Begin | Flows | PnL | End    |
| ------ | ----- | ----- | --- | ------ |
| Q1     | 1,000 | 200   | 50  | 1,250  |
<!-- mdv: endtable -->
<!-- mdv: endsection -->

@tables/returns

The product of (1+rᵢ) over named period rows must equal the stated cumulative row within tolerance (tol=<pp>). Silent when any named row/column is absent or unparseable. Warns only.

<!-- mdv: section -->
## Status
<!-- mdv: table @tables/returns=Return;from=Jan|Feb|Mar;to=Q1 -->
| Period | Return |
| ------ | ------ |
| Jan    | 1.0%   |
| Feb    | 2.0%   |
| Mar    | 3.0%   |
| Q1     | 6.11%  |
<!-- mdv: endtable -->
<!-- mdv: endsection -->

@tables/percent-of

Every n (p%) cell recomputes p from n and the column header's declared (N=…) denominator. Skips columns without an N header and non-matching cells; flags counts exceeding N. tol=<pp> widens the tolerance. Warns only.

<!-- mdv: section -->
## Status
<!-- mdv: table @tables/percent-of= -->
| Preferred term | Drug (N=120) | Placebo (N=118) |
| -------------- | ------------ | --------------- |
| Nausea         | 12 (10.0%)   | 6 (5.1%)        |
<!-- mdv: endtable -->
<!-- mdv: endsection -->

On this page