Filters overview

Filters overview

ThoughtSpot provides multiple types of filters for various object types, which can be applied in a layered fashion.

Order of filter layersπŸ”—

The behavior of each filter type and the mechanism for setting filters can differ widely. There are different types of filters, which can be applied in the following order:

All types of filters result in some form of WHERE clause being applied to the resulting queries generated by ThoughtSpot, or no query being issued if the resulting logic is always false.

RLS RulesπŸ”—

RLS rules are defined at the ThoughtSpot Table object level.

Once in place, they always apply within the query generation layer.

Multiple RLS Rules are appended to the query via OR logic, rather than AND.

ABAC filter rulesπŸ”—

Filters and parameter values defined via ABAC token that apply at the data model layer are locked-in and always apply until changed or removed by a new token request.

The ABAC filter rules and runtime filters are converted into SQL with the same logic:

  1. clauses are appended via AND

  2. filters are applied to exact matching Worksheet Column names

Any data restrictions resulting from filter rules will be seen in the visible filter UI of the Liveboard filters and search_query filters layers, but there is no visible filter UI directly related to these filtering layers.

Worksheet filtersπŸ”—

Worksheet objects can have Parameters, formulas, and filters.

End users cannot affect the formulas or filters, which are always applied, but any Parameters that are used in a formula can be set by these other methods.

To create an adjustable formula-filter that is secure, use the ABAC filtering layer to set the value of the parameter programmatically.

If the user can edit the Parameter, use the runtime Parameters layer to set the Parameter value.

Runtime filters and ParametersπŸ”—

You can define runtime filters and runtime parameters within the browser for a given object at load time.

Filters and parameters set for ABAC token cannot be overridden by setting runtime filters or Parameters in the browser.

Liveboard filtersπŸ”—

Liveboard filters display at the top of a Liveboard. When clicked, a modal filtering dialog appears with filter options appropriate for the data type.

The author of a Liveboard can set default values for Liveboard filters and other options on each filter when editing the Liveboard.

The entire header where the Liveboard filters display can be hidden and then their interaction triggered via events:

const embed = new LiveboardEmbed('#embed', {
  ... // other liveboard view config
  hideLiveboardHeader:true,
});

EventsπŸ”—

There is no programmatic way to adjust the filter values before loading the Liveboard, but there are events that can adjust the values after the Liveboard is rendered.

OpenFilter eventπŸ”—

If you have hidden the Liveboard header, you can trigger the opening of the filter modal dialog by using the HostEvent.OpenFilter:

LiveboardEmbed.trigger(HostEvent.OpenFilter,
 { columnId: '<column-GUID>'})

UpdateFilters eventπŸ”—

The HostEvent.UpdateFilters directly updates the values of the target Liveboard filter:

liveboardEmbed.trigger(HostEvent.UpdateFilters, {
    filter: {
        column: "date",
        oper: "EQ",
        values: ["JULY","2023"],
        type: "MONTH_YEAR"
       }
   });

The Liveboard filter exists already on the Liveboard for the HostEvent.UpdateFilters to work.

For more information and examples, see Liveboard filters.

GetFilters and GetParameters eventsπŸ”—

If you want to build your own filter UI within the embedding app, you can find out details of the Liveboard and runtime filters that are defined using the HostEvent.GetFilters. There is an equivalent HostEvent.GetParameters to get the currently set Parameter values:

const data = await liveboardEmbed.trigger(HostEvent.GetFilters);
    console.log('data', data);

liveboardEmbed.trigger(HostEvent.GetParameters).then((parameter) => {
 console.log('parameters', parameter);
});

Note that HostEvent.GetFilters and HostEvent.GetParameters return a promise directly rather than taking a callback function as their second argument.

FilterChanged and ParameterChanged eventsπŸ”—

You can also listen for the user’s interactions with the filters using the EmbedEvent.FilterChanged.

There is an equivalent EmbedEvent for Parameters called EmbedEvent.ParameterChanged.

Liveboard cross filtersπŸ”—

Liveboard users can apply filters across all visualizations based on the current selection using the Filter menu option from the contextual menu. For more information, see Liveboard cross filter.

If the column already has a Liveboard filter and the user applies cross filters, the cross filter replaces the values in the currently applied Liveboard filter. If there is no Liveboard filter applied to a column and user applies a cross filter, a new filter chip with cross filter values is displayed in the header area. This filter chip is removed when the cross filter is cleared.

CrossFilterChanged eventπŸ”—

Whenever any user action affects a cross filter, a EmbedEvent.CrossFilterChanged fires, which can be listened to for register details about the action that happened.

UpdateCrossFilter eventπŸ”—

You can programmatically trigger an action to update a cross filter using HostEvent.UpdateCrossFilter:

liveboardEmbed.trigger(HostEvent.UpdateCrossFilter, {
     vizId: 'b535c760-8bbe-4e6f-bb26-af56b4129a1e',
     conditions: [
       { columnName: 'Category', values: ['mfgr#12','mfgr#14'] },
       { columnName: 'color', values: ['mint','hot'] },
   ],
});

Search query filtersπŸ”—

The lowest layer of filters is defined as part of the search query for a given Answer or visualization on a Liveboard.

The filter terms are saved as part of the search_query of the object, visible in TML.

When viewing an Answer or a visualization in the Edit mode, you will see the filter UI for search_query filters above the chart or table. These filters are not visible on a Liveboard.

Liveboard filters override search query filtersπŸ”—

When viewing a visualization on a Liveboard, any Liveboard filter on the same column as a search_query filter will fully override the values.

EventsπŸ”—

There is no specific event to update search_query filters in the SearchEmbed component or the Liveboard edit mode.

You can set your app to listen to EmbedEvent.QueryChanged and trigger the HostEvent.GetTML event to get a new TML generated for the search_query string after an update.