# Group values into bins

Shape / columns

discretise, bucket, tile, histogram bins

Page: <https://meridian.online/operations/group-values-into-bins>

## Status

Runs as a SQL step.

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

## The DuckDB step

equal-width bins

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, floor(amount / 100) * 100 AS bin_floor FROM orders WHERE amount IS NOT NULL;
SELECT * FROM result;
SELECT equi_width_bins(min(amount), max(amount), 5, true) AS edges FROM orders;
SELECT CASE WHEN ((SELECT count(*) FILTER (WHERE bin_floor = 0) = 4 AND count(*) FILTER (WHERE bin_floor = 500) = 2 AND max(bin_floor) FILTER (WHERE order_id = 10) = 200 FROM result)) THEN 'as expected' ELSE error('the amounts did not fall in the bins expected') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## Variants

- [Bin by chosen boundaries](https://meridian.online/operations/group-values-into-bins/bin-by-chosen-boundaries): Assign values to named ranges set by given break points, bounds or a threshold.
- [Bin into groups of equal size](https://meridian.online/operations/group-values-into-bins/bin-into-groups-of-equal-size): Assign each row to a tile or quantile so that each bin holds about the same number of rows.
- Bin into equal-width ranges: Assign each value to one of a number of ranges of the same width.
- Bin against a target column: Choose bin boundaries that best separate the values of a class or label column.

## 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: [`Multi-Field Binning`](https://help.alteryx.com/current/en/designer/tools/preparation/multi-field-binning-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Tile`](https://help.alteryx.com/current/en/designer/tools/preparation/tile-tool.html) (read 2026-09-27)
- Bruin: [`bruin.width_bucket(expr, min_value, max_value, num_buckets)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- dbt-utils: [`width_bucket`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- Duckle: [`Bucketize`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Create buckets`](https://help.easymorph.com/doku.php?id=transformations:createbuckets) (read 2026-09-27)
- 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`](https://api.hub.knime.com/nodes/*f6JNvzVp3pcflXaI?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Binner (Apply)`](https://api.hub.knime.com/nodes/*EB2Tw7Zk6xnooB9m?details=full) (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: [`CAIM Applier`](https://api.hub.knime.com/nodes/*ZHq1NFAmnayQvZBk?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`CAIM Binner`](https://api.hub.knime.com/nodes/*IFxccsQELocGGQWE?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`DB Binner`](https://api.hub.knime.com/nodes/*Sd8c1CzpChHCo_Qn?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`DB Binner (Apply)`](https://api.hub.knime.com/nodes/*fyJKtYKjBMLx8ima?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)
- Polars: [`Expr.qcut`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- RapidMiner Studio: [`Discretize by Binning`](https://docs.rapidminer.com/latest/studio/operators/cleansing/binning/discretize_by_bins.html) (read 2026-09-27)
- RapidMiner Studio: [`Discretize by Entropy`](https://docs.rapidminer.com/latest/studio/operators/cleansing/binning/discretize_by_entropy.html) (read 2026-09-27)
- RapidMiner Studio: [`Discretize by Frequency`](https://docs.rapidminer.com/latest/studio/operators/cleansing/binning/discretize_by_frequency.html) (read 2026-09-27)
- RapidMiner Studio: [`Discretize by Size`](https://docs.rapidminer.com/latest/studio/operators/cleansing/binning/discretize_by_size.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)
- Tableau Prep: [`NTILE`](https://help.tableau.com/current/prep/en-us/prep_function_reference.htm) (read 2026-09-27)
- Tableau Prep: [`Tile`](https://help.tableau.com/current/prep/en-us/prep_calculations.htm) (read 2026-09-27)
- Trifacta: [`Bin column`](https://help.alteryx.com/aac/en/trifacta-classic/reference/transformation-reference.html) (read 2026-09-27)
