# Count values

Shape / table

frequency table, value counts, count by

Page: <https://meridian.online/operations/count-values>

## Status

Runs as a SQL step.

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

## The DuckDB step

a frequency table with share and bar

It reads the `orders` table the proofs share. Create it 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);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT product, count(*) AS n, round(100.0 * count(*) / sum(count(*)) OVER (), 1) AS pct,
       bar(count(*), 0, max(count(*)) OVER (), 20) AS histogram
FROM orders GROUP BY product ORDER BY n DESC;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT sum(n) = 10 AND sum(pct) = 100 AND max(n) FILTER (WHERE product = 'widget') = 4 AND max(pct) FILTER (WHERE product = 'widget') = 40 FROM result)) THEN 'as expected' ELSE error('the counts do not sum to 10 rows and 100 percent with widget at 4') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Alteryx Designer: [`Frequency Table`](https://help.alteryx.com/current/en/designer/tools/data-investigation/frequency-table-tool.html) (read 2026-09-27)
- dbt-utils: [`get_column_values`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- Duckle: [`Histogram`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- KNIME Analytics Platform: [`Value Counter`](https://api.hub.knime.com/nodes/*cB9KE6SSG6RhNZNp?details=full) (read 2026-09-27)
- Apache NiFi: [`CalculateRecordStats`](https://nifi.apache.org/components/org.apache.nifi.processors.standard.CalculateRecordStats/) (read 2026-09-27)
- OpenRefine: [`Best candidate's name match`](https://openrefine.org/docs/manual/reconciling#reconciliation-facets) (read 2026-09-27)
- OpenRefine: [`Best candidate's type match`](https://openrefine.org/docs/manual/reconciling#reconciliation-facets) (read 2026-09-27)
- OpenRefine: [`Best candidate's types`](https://openrefine.org/docs/manual/reconciling#reconciliation-facets) (read 2026-09-27)
- OpenRefine: [`By judgment`](https://openrefine.org/docs/manual/reconciling#reconciliation-facets) (read 2026-09-27)
- OpenRefine: [`Custom text facet`](https://openrefine.org/docs/manual/facets#custom-text-facet) (read 2026-09-27)
- OpenRefine: [`Judgment action timestamp`](https://openrefine.org/docs/manual/reconciling#reconciliation-facets) (read 2026-09-27)
- OpenRefine: [`Judgment action type`](https://openrefine.org/docs/manual/reconciling#reconciliation-facets) (read 2026-09-27)
- OpenRefine: [`Text facet`](https://openrefine.org/docs/manual/facets#text-facet) (read 2026-09-27)
- OpenRefine: [`Word facet`](https://openrefine.org/docs/manual/facets#word-facet) (read 2026-09-27)
- Polars: [`Expr.unique_counts`](https://docs.pola.rs/api/python/stable/reference/expressions/computation.html) (read 2026-09-27)
- Polars: [`Expr.value_counts`](https://docs.pola.rs/api/python/stable/reference/expressions/computation.html) (read 2026-09-27)
- VisiData: [`freq-col`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/freqtbl.py#L204) (read 2026-09-23)
- VisiData: [`freq-keys`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/freqtbl.py#L205) (read 2026-09-23)
- VisiData: [`freq-row`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/freqtbl.py#L208) (read 2026-09-23)
