View as Markdown

Fields and filters

Filtering UI

The member editor dialog with search, select all and a virtualized member list without a node limit, the label and value filter forms, and the onBeforeFilterChange, onFilterChange and onBeforeMemberEditorOpen events.

Filters are model data: pivotModel.filterBy[field] holds one filter per field, a member filter ({ include } or { exclude }), a label filter or a value filter. Their semantics are in Filtering and sorting; this page covers the dialog that edits them.

Member editor

"Filter…" in a field menu (field list, axis bar) opens the member editor for that field, a modal dialog:

  • Include (member filter): a search box, "Select all" (indeterminate when some members are checked; with a search it toggles only the matching members) and a checkbox list of every member with its row count.
  • Label filter: an operator (equal, notEqual, contains, doesNotContain, startsWith, endsWith, greaterThan, lessThan, between, ...) and one or two values.
  • Value filter: a measure (its measure id: field, or field#aggregate when one field is summarized twice), an operator (greaterThan, between, top, bottom, ...) and one or two numbers.

OK writes the filter; an empty label or value input clears it. Checking every member writes no filter; unchecking a few writes an exclude filter so members that appear later stay visible. OK is disabled with no member checked. Escape or Cancel closes without a change, and focus returns to the field button. "Clear filter" in the field menu removes the filter.

pivot.setFilter('country', { include: ['Japan', 'France'] });
pivot.setFilter('product', { label: { operator: 'startsWith', value: 'B' } });
pivot.setFilter('country', { value: { measure: 'amount', operator: 'top', value: 3 } });
pivot.setFilter('country', null); // clear

Large member lists

The member list is virtualized (only the visible checkboxes are mounted), so a field with 100,000 members opens as fast as one with ten. There is no maxNodeLimitInMemberEditor and no load-on-demand mode: members come from the engine's field index, or from one facet request for a remote pivot.

The list is a multi-select listbox: ArrowUp / ArrowDown, Home / End and PageUp / PageDown move through the members and Space checks the active one. The three filter kinds are a radio group above it.

Events

Event Payload
onBeforeMemberEditorOpen { field, source }; preventDefault() keeps the dialog closed
onBeforeFilterChange { field, filter, previousFilter, source }; preventDefault() cancels
onFilterChange the same, after the change
const pivot = usePivot({
  data,
  defaultPivotModel: model,
  onBeforeMemberEditorOpen: (event) => {
    if (event.field === 'internalCode') event.preventDefault();
  },
  onBeforeFilterChange: (event) => {
    // Keep at least one region visible.
    if (event.field === 'region' && event.filter && 'include' in event.filter && event.filter.include.length === 0) event.preventDefault();
  },
});

A filter also fires onBeforePivotModelChange / onPivotModelChange with action: 'filter' (State and events).

Member, label and value filters

Open demo

Include and exclude member filters, label and value (top N) filters from code and the member editor, a 2,500-member virtualized list, and the cancellable filter and member editor events.

Country
2024
2025
2026
Grand total
Brazil
$190,900
$191,000
$191,100
$573,000
Canada
$202,900
$201,100
$201,200
$605,200
France
$207,300
$207,400
$207,500
$622,200
Germany
$206,000
$206,100
$206,200
$618,300
India
$202,800
$202,900
$202,700
$608,400
Japan
$201,500
$201,600
$201,400
$604,500
Kenya
$200,200
$200,300
$200,100
$600,600
Mexico
$197,000
$196,800
$196,900
$590,700
Norway
$195,700
$195,500
$195,600
$586,800
Spain
$194,400
$194,200
$194,300
$582,900
Grand total
$1,998,700
$1,996,900
$1,997,000
$5,992,600
Use a button, or the filter icon of Customer, Product or Country on the axis bar.