LiveboardEmbed.trigger(HostEvent.OpenFilter,
{ columnId: '<column-GUID>'})
Filters overview
ThoughtSpot Embedded provides a robust filtering framework for Liveboards, Answers, visualizations, and other ThoughtSpot objects with multiple filter types and layered application logic. Filters can be configured using the Visual Embed SDK events and parameters when embedding, applied at runtime, or via UI-driven workflows.
Filter types and application 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:
-
Row-level security (RLS) Rules
Rules are defined at the table level and applied during query generation to all objects derived from that table. Rules can be defined based on the logged-in user, their group memberships, or custom variables.
RLS rules secure data and cannot be altered by the logged-in user.
RLS rules can also be used, along with custom variables and the JSON Web Token (JWT) generated for the user, to implement Attribute-Based Access Control (ABAC). -
Data Model filters
Models can have parameters, formulas, and filters.
Embedding application users cannot affect the formulas or filters, which are always applied, but Parameters used in a formula can be set by other methods.
If the user can edit the parameter, use the runtime parameters layer to programmatically set its value. -
Runtime filters and Runtime Parameters
You can define runtime filters and runtime parameters within the browser for a given object at load time. Filters and parameters can be set using the Visual Embed SDK, REST API, or URL query parameters and updated via host events in the Visual Embed SDK.NoteRuntime filters do not display as UI filter components.
-
Liveboard filters
Liveboard filters apply to all visualizations on the Liveboard and are visible as UI components at the top of a Liveboard page. When a filter is clicked, a modal with filter options appropriate for the data type is displayed.
Liveboard users can add or modify filters as needed. If you are embedding a Liveboard that includes preset filters, you can programmatically update, reset, or remove filters using theHostEvent.UpdateFilters. -
Liveboard cross filters
Cross filters are ad-hoc filters based on user selection. These filters are used for brushing and linking Liveboard visualizations.
Cross filters are supported only on attribute columns. -
Search query filters
Set via the search query string in Answers and visualizations, not visible as UI filter components on a Liveboard, but can be viewed in Explore or Edit modes.
The lowest layer of filters is defined in the search query for a given Answer or visualization on a Liveboard.
The filter terms are saved as part of thesearch_queryof the object, visible in TML.
Filter attributesπ
When specifying a column for filtering, you must use the exact column name as defined in the model. Filters can be applied to string, number, boolean, Date, Datetime, and time data types.
For the DATE and DATE_TIME data types, some filter types may require the date and time values to be specified in the Epoch time format.
All operations result in a WHERE clause being applied to the queries generated by ThoughtSpot, or no query being issued if the logic is always false.
A data filter object in ThoughtSpot typically includes the following attributes:
column,columnName, orcolumnId-
The name of the column to filter on. For example,
item typeorproduct. The column value must match the actual column name in the ThoughtSpot model. If the model uses column aliases, use the base column name, not the alias. This attribute is defined ascol1,col2,col3in the object URLs and REST API requests, ascolumnNamein theruntimeFiltersarray in the Visual Embed SDK. The filter object for host events in the SDK allowscolumnorcolumnName.If there are multiple columns with the same name, you can use the
WORKSHEET_NAME::COLUMN_NAMEformat; for example,"(Sample) Retail - Apparel::city". operoroperator-
The supported operators include:
Operator Description Number of Values EQequals
1
NEnot equal to
1
LTless than
1
LEless than or equal to
1
GTgreater than
1
GEgreater than or equal to
1
CONTAINScontains
2
BEGINS_WITHbegins with
1
ENDS_WITHends with
1
BW_INC_MAXbetween inclusive of the higher value
2
BW_INC_MINbetween inclusive of the lower value
2
BW_INCbetween inclusive
2
BWbetween non-inclusive
2
INis included in this list of values
multiple
NOT_INis not included in this list of values
multiple
- values
-
An array of one or more values to filter by. The values must match the data type of the column.
- type
-
Specifies the type for date filters. Supported types include
YESTERDAY,TODAY,TOMORROW,EXACT_DATE,EXACT_DATE_RANGE,LAST_N_PERIOD,NEXT_N_PERIOD,THIS_PERIOD,PERIOD_TO_DATE,YEAR_ONLY,MONTH_YEAR, andQUARTER_YEAR.
|
Note
|
|
Applying filters before and after loadπ
-
Runtime filters can be applied at load via Visual Embed SDK, REST API, or URL parameters.
-
Liveboard filters cannot be applied at load. However, they can be updated using
HostEvent.UpdateFiltersin the SDK. -
Search query filters can be applied at load by specifying them in the initial search query when embedding an Answer or Spotter session. For example, in Spotter embed, you can use the
searchQueryproperty to set a pre-defined search (including filters) at load.When you view an Answer or visualization in Edit mode, the filter UI for search query filters appears above the chart or table. These filters are not shown on a Liveboard. If a Liveboard filter is applied to the same column as a search query filter, the Liveboard filter will override the search query filter values.
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 the 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.
Whenever any user action affects a cross filter, a EmbedEvent.CrossFilterChanged fires, which can then be used to trigger a specific action.
Updating filters using host 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 action of opening a filter modal dialog using HostEvent.OpenFilter:
UpdateFilters eventπ
The HostEvent.UpdateFilters directly updates the values of the target of an existing filter thatβs currently applied on a Liveboard:
liveboardEmbed.trigger(HostEvent.UpdateFilters, {
filter: {
column: "date",
oper: "EQ",
values: ["JULY","2023"],
type: "MONTH_YEAR"
}
});
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.
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'] },
],
});
Updating date filtersπ
To update date filters in an embedded Liveboard, visualization, or saved answer, use HostEvent.UpdateFilters.
When updating filters using HostEvent.UpdateFilters, you must include the date filter type along with the time period to apply a rolling or fixed time windows.
|
Note
|
|
The following table lists the supported filter types and examples for each type:
| Type | Description | Example |
|---|---|---|
| Specify the |
|
| Specify the |
|
| Specify the |
|
| Allows filtering column data to show details for the exact date, before or after the date. For example, to filter data for dates greater than |
|
| Specify the start date and end date in the |
|
| Specify the period. You must include the |
|
| Specify the period. You must include the |
|
| Specify the period. You must include the |
|
| Specify the period. You must include the |
|
| Specify the year. For example, 2023. |
|
| Specify the month and year in the |
|
| Specify the quarter and year in the |
|
Updating runtime filtersπ
For information about runtime filters update, see Runtime filters documentation.
Removing filtersπ
To remove a specific filter, pass the empty values array, as shown in the following examples:
Runtime filters
liveboardEmbed.trigger(HostEvent.UpdateRuntimeFilters, [{
columnName: "item type",
operator: RuntimeFilterOp.EQ,
values: [] // set an empty array to clear runtime filters
}]);
Liveboard filters
liveboardEmbed.trigger(HostEvent.UpdateFilters, {
filters: [{
column: "state", // columnName is also a valid parameter.
oper: "EQ",
values: [] // set an empty array to clear filters
}]
});
Setting empty values via HostEvent.UpdateFilters removes only the filter values; it does not remove or hide the filter chips from the Liveboard.