Using Filters in Tableau Next Components

Analytics components leverage filters to narrow down the data displayed. When embedding these components, filters are crucial for refining the data your users see, allowing them to concentrate on specific details. For instance, if a component presents account insights, you can apply a filter based on account ID to ensure only information relevant to the account the user is currently viewing is rendered.

Filters are supported for AnalyticsDashboard and AnalyticsVisualization components only.

For embedded components, perform filter operations only after the component has rendered. Alternatively, you can use the COMPONENT_LOADED event, performing filter operations within its callback.

Filter methods utilize UnifedFilterJson for data input and output.

The syntax for UnifiedFilterJson is

The dataSource is the API name of the semantic model the component is retrieving the data from. The fieldName is the API name of a field present in the data source. Use one of the FilterOperation enumerated values to specify the filter action. Then specify one or more values to use for the filter. These values can be text, numerical, boolean, or date types, but the types can’t be mixed. They must all be the same type.

A natural language filter like “show the data from the semantic model, C360SDM, where the account id equals 3054X'”, is represented in UnifiedFilterJson as:

To see the current filters for a component, use the getFilters method. This method returns a list of UnifiedFilterJson objects.

To apply filters in your component, use the applyFilters method.

To clear all filters for your component, use the clearFilters method.

Valid values for the FilterOperator enumeration are:

  • Between
  • Contains
  • ContainsIgnoreCase
  • CurrentFiscalQuarter
  • CurrentFiscalQuarterToDate
  • CurrentFiscalYear
  • CurrentFiscalYearToDate
  • CurrentMonth
  • CurrentMonthToDate
  • CurrentQuarter
  • CurrentQuarterToDate
  • CurrentWeek
  • CurrentYear
  • CurrentYearToDate
  • DoesNotEndWith
  • DoesNotEndWithIgnoreCase
  • DoesNotEquals
  • DoesNotEqualsIgnoreCase
  • DoesNotStartWith
  • DoesNotStartWithIgnoreCase
  • EndsWith
  • EndsWithIgnoreCase
  • Equals
  • EqualsIgnoreCase
  • GreaterThan
  • GreaterThanOrEqualTo
  • IsEmpty
  • IsNotEmpty
  • IsNotNull
  • IsNull
  • LastNDays
  • LessThan
  • LessThanOrEqualTo
  • NextFiscalQuarter
  • NextFiscalYear
  • NextMonth
  • NextNDays
  • NextQuarter
  • NextWeek
  • NextYear
  • NotContains
  • NotContainsIgnoreCase
  • NotInValues
  • PreviousFiscalQuarter
  • PreviousFiscalQuarterToDate
  • PreviousFiscalYear
  • PreviousFiscalYearToDate
  • PreviousMonth
  • PreviousMonthToDate
  • PreviousQuarter
  • PreviousQuarterToDate
  • PreviousWeek
  • PreviousYear
  • PreviousYearToDate
  • StartsWith
  • StartsWithIgnoreCase
  • Tomorrow
  • Values
  • Yesterday

Filters require specific values to work as expected and should be tested before production use. If you add code to let your users define filters, make sure you build in validation and error handling.

Here are possible errors for filters at runtime.

Error CodeError MessageResolution
INTERNAL_ERRORInvalid fieldName in filter JSONCheck the fieldName in the filter code or prompt your user to provide a valid fieldName value.
INTERNAL_ERRORInvalid filter operator in filter JSONCheck the operator in the filter code or prompt your user to provide a valid operator value.
INTERNAL_ERRORInvalid data source in filter JSONCheck the dataSource in the filter code or prompt your user to provide a valid dataSource value.
INTERNAL_ERRORCannot find enum for name <OperatorName>Check the operator in the filter code or prompt your user to provide a valid operator value.
INTERNAL_ERRORInvalid values in the filter JSONCheck the values in the filter code or prompt your user to provide valid values.

See Also