Birch UI v0.1
Pricing

Filtering & sortingPivot Studio

Member, label, value and top-N filters, report filters in the Filters zone, and sorting rows and columns by label or by any measure.

Open .md

Users filter from the filter button on a chip or the Filter… entry in its menu, and sort from the chip menu or by clicking table headers. Both are stored in the report, so they are saved and restored with it.

Filter types#

A field's filter is a FieldFilter with up to four parts, all of which apply together:

TypeScript
studio.setFilter('store', {
  exclude: ['Online Clearance'],
  label: { op: 'beginsWith', value: 'London' },
  value: { op: 'gt', measure: 'sum(revenue)', value: 50_000 },
  top: { type: 'top', count: 5, measure: 'sum(revenue)' },
});

studio.setFilter('store', null);
FieldFilterinterface@birchui/pivot-studioFull reference
PropertyTypeDescription
includeoptionalstring[]—
excludeoptionalstring[]—
labeloptionalLabelFilter—
valueoptionalValueFilter—
topoptionalTopFilter—

Member filters#

include keeps only the listed members and exclude removes them. Member keys are the raw values as text: 'North', '2026', and for date parts numbers such as '1' to '4' for quarters. The blank member's key is an empty string.

TypeScript
studio.setFilter('channel', { exclude: ['Marketplace'] });
studio.setFilter('orderDate.quarter', { include: ['3', '4'] });
studio.setFilter('region', { include: ['North', 'South', ''] });

getMembers(field) lists a field's members with their keys and labels, which is what you need to build your own filter UI.

Label filters#

A label filter matches member labels:

op Keeps members whose label
contains / notContains Contains, or does not contain, the text
beginsWith / endsWith Starts or ends with the text
equals / notEquals Is, or is not, exactly the text

Matching ignores case unless you set caseSensitive: true.

TypeScript
studio.setFilter('product', { label: { op: 'contains', value: 'merino' } });

Value filters#

A value filter keeps members whose aggregated value meets a condition, for example stores with more than £50,000 of revenue:

op Condition
gt, gte, lt, lte Greater than, at least, less than, at most value
eq, ne Equal or not equal to value
between, notBetween Inside or outside value to valueTo, inclusive

measure is a measure ID such as 'sum(revenue)', or { field, aggregation } for a measure that is not in the Values zone:

TypeScript
studio.setFilter('store', { value: { op: 'gte', measure: { field: 'units', aggregation: 'sum' }, value: 1_000 } });

Top and bottom N#

top keeps the count members with the highest (type: 'top') or lowest (type: 'bottom') value of a measure:

TypeScript
studio.setFilter('product', { top: { type: 'top', count: 10, measure: 'sum(margin)' } });

For a field in Rows or Columns, value and top filters are applied within each parent: with region above product in Rows, the filter above keeps the ten most profitable products in each region, not ten overall. For a field that is not in Rows or Columns, the filter is applied across all data.

The filter dialog#

The dialog that users open from a chip has three parts:

  • Members: a checklist with Search members and a select-all option. Each member is a labelled checkbox.
  • Label filter: a condition (Contains, Does not contain, Begins with, Ends with, Equals, Does not equal) and the text.
  • Value filter and Top / bottom: a condition, the measure, and the value or number of members.

Apply commits the filter, Clear filter removes it and Cancel or Escape closes the dialog without changes. The dialog traps focus while open and returns it to the chip when it closes.

Report filters#

Fields in the Filters zone filter the data without adding rows or columns, the way a page filter works in a spreadsheet. A common pattern is a year or channel filter above a store-by-month report:

TypeScript
const report: PivotReport = {
  slice: {
    rows: [{ field: 'store' }],
    columns: [{ field: 'orderDate.month' }],
    values: [{ field: 'revenue' }],
    filters: [{ field: 'orderDate.year' }, { field: 'channel' }],
  },
  filters: {
    'orderDate.year': { include: ['2026'] },
    channel: { include: ['Store'] },
  },
};

Filters are stored by field in report.filters, separately from the zones. Moving a field between zones keeps its filter; removing it from the report removes the filter.

Sorting#

Each row and column field has its own sort, stored on its slice entry:

Sort Setting Order
By label, ascending (default) sort: 'asc' Numbers numerically, dates and date parts in calendar order, text alphabetically with numbers inside text compared numerically ("Store 9" before "Store 10")
By label, descending sort: 'desc' The reverse
By a measure sortBy: { measure, dir } By each member's total for the measure, largest first with dir: 'desc'
By a measure in one column sortBy: { measure, dir, path } By the member's value in the column at path, for example ['2026', '4'] for Q4 2026

Blank members always sort last. Members with equal values keep their label order.

TypeScript
studio.setSort('region', 'desc');
studio.setSort('store', { measure: 'sum(revenue)', dir: 'desc' });
studio.setSort('store', { measure: 'sum(revenue)', dir: 'desc', path: ['2026', '4'] });

Sorting applies within each parent: stores are sorted inside each region.

Sorting from the table#

Clicking a header in the table sorts the rows:

  • A row label header sorts the row fields by label, alphabetically or in reverse.
  • A value column header sorts every row field by that column's value, so clicking "Q4 2026 · Revenue" orders regions and the stores within them by Q4 revenue.

Each sort is announced, for example "Rows sorted by Revenue, largest first". The chip menu offers the same choices plus sorting by each measure's total, and sorting the column fields.

Filters, totals and calculations#

Totals and percentages are computed after filtering: when stores are filtered to the top five, the region subtotals and the grand total add up the visible stores only, and "% of grand total" is a share of the filtered total. Drill-through returns only records that pass the filters.

↑ ↓ to move, Enter to open, Esc to close