# Bin by chosen boundaries

Shape / columns

A variant of [Group values into bins](https://meridian.online/operations/group-values-into-bins).

Assign values to named ranges set by given break points, bounds or a threshold.

Page: <https://meridian.online/operations/group-values-into-bins/bin-by-chosen-boundaries>

## Status

Runs as a SQL step.

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

## The DuckDB step

assign amounts to named ranges set by break points, and to a threshold

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 order_id, amount,
       CASE WHEN amount < 100 THEN 'low' WHEN amount < 300 THEN 'mid' WHEN amount >= 300 THEN 'high' END AS band,
       amount >= 200 AS over_threshold
FROM orders;
SELECT * FROM result ORDER BY order_id;
SELECT CASE WHEN ((SELECT list(band ORDER BY order_id) FROM result) = ['mid', 'low', 'high', NULL, 'low', 'high', 'low', 'high', 'low', 'mid'] AND (SELECT list(over_threshold ORDER BY order_id) FROM result) = [false, false, true, NULL, false, true, false, true, false, true]) THEN 'as expected' ELSE error('the amounts were not placed in low below 100, mid from 100 to below 300 and high from 300, or the threshold 200 was not applied') 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).

- Apache Hop: [`Number range`](https://hop.apache.org/manual/latest/pipeline/transforms/numberrange.html) (read 2026-09-27)
- Ibis: [`Bucket`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/histograms.py) (read 2026-09-27)
- KNIME Analytics Platform: [`Binner (Dictionary)`](https://api.hub.knime.com/nodes/*CpXT9JnZ2bDjUPeT?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Numeric Binner`](https://api.hub.knime.com/nodes/*_y-V6DTqskd8w-IM?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Numeric Binner (PMML)`](https://api.hub.knime.com/nodes/*7TlC9PN9CJf1djTS?details=full) (read 2026-09-27)
- mlpack: [`mlpack_preprocess_binarize`](https://www.mlpack.org/doc/user/bindings/cli.html) (read 2026-09-27)
- Pentaho Data Integration: [`Number range`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Polars: [`Expr.cut`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- RapidMiner Studio: [`Discretize by User Specification`](https://docs.rapidminer.com/latest/studio/operators/cleansing/binning/discretize_by_user_specification.html) (read 2026-09-27)
- RapidMiner Studio: [`Numerical to Binominal`](https://docs.rapidminer.com/latest/studio/operators/blending/attributes/types/numerical_to_binominal.html) (read 2026-09-27)
