Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TanStack · Function

getFacetedUniqueValues

Returns a Map of unique facet values to their occurrence counts. Use it to build checkbox lists, select menus, autocomplete suggestions, or other faceted controls.

How it works

This column API reads the faceted row model and returns each distinct facet value alongside its occurrence count. The required faceting factories must be registered in the table configuration; custom getUniqueValues logic can make one row contribute several values or map rendered values into facet buckets.

Syntax

column.getFacetedUniqueValues(): Map<any, number>

Returns

Map<any, number>

Key points

  • The returned Map associates every facet value with its occurrence count.
  • Transform the Map into a sorted list when populating autocomplete or select controls.
  • With ordinary scalar values, each occurrence count normally equals the number of rows containing that value.
  • The column's getUniqueValues option allows a single row to contribute multiple facet values.
  • Use custom facet bucket keys without changing the original accessor value used for rendering.

Common mistakes

  • When getUniqueValues returns multiple values for one row, counts represent value occurrences rather than unique-row counts, so their total may exceed the row count.
  • Ensure each facet value is returned at most once per row when counts must represent rows.
  • Register the faceted-unique-values row-model factory; otherwise this API cannot provide its unique values and counts.

Example: Build facet suggestions

const suggestions = Array.from(
  column.getFacetedUniqueValues().entries()
)
  .sort((a, b) => b[1] - a[1])
  .slice(0, 5000);

Creates a frequency-sorted list of facet values for an autocomplete or select control.

When to use it

Checkbox or select filters

A filter UI needs to show each available value with its frequency.

Autocomplete suggestions

A search field should suggest values present in the faceted data.

Custom facet buckets

Values should be grouped into application-defined categories for filtering.

Interview questions

QWhat does getFacetedUniqueValues return, and what is it useful for?

It returns a Map whose keys are facet values and whose values are occurrence counts. The result is intended for controls such as checkboxes, select menus, and autocomplete suggestions.

Follow-up: How would you constrain a large suggestion list? Convert the Map entries to an array, sort or rank them, and take only the needed leading values.

QWhat configuration is required before using this column API?

The API depends on faceting configuration. For client-side faceting, the table needs the faceted row model and the factory that computes unique values and counts.

Follow-up: What if faceting is server-side? Supply a getFacetedUniqueValues table option that resolves and returns the server-provided Map.

QHow should occurrence counts be interpreted?

For scalar columns, each row normally contributes one value, so a count also corresponds to a row count. With getUniqueValues, a row can contribute multiple values, and counts then describe occurrences.

Follow-up: How can a custom facet bucket differ from the displayed value? Return a bucket key from getUniqueValues while retaining the accessor value for rendering and other table behavior.

  • createFacetedRowModel
  • createFacetedUniqueValues
  • getUniqueValues
  • getFacetedRowModel

Source: Faceting (React) Guide | TanStack Table React Docs. Checked 2026-10-15.