liveboardEmbed.trigger(HostEvent.OpenFilter,
{ columnId: '<column-GUID>'})
Filter types and application layers
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 Visual Embed SDK events and parameters at embed time, applied at runtime, or set through UI-driven workflows.
Overviewπ
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 in 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.Note-
Runtime filters do not display as UI filter components.
-
The SDK processes at most 49 entries per embed. Any objects at index 50 or beyond are silently dropped without an error or warning. See Runtime filter limit for more information.
-
-
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 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". operator,oper, orop-
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.UpdateFilters in 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 searchQuery property 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 on the same column as a search query filter, the Liveboard filter overrides 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 on 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 in Visual Embed SDKπ
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 an existing filter 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 via host eventsπ
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 rolling or fixed time windows.
|
Note
|
|
The following table lists the supported filter types and examples for each type:
| Type | Description |
|---|---|
|
|
|
|
|
|
| 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
|
Overriding filters during Liveboard export via REST APIπ
The override_filters parameter on the Liveboard report API
(POST /api/rest/2.0/report/liveboard) lets you programmatically override filters when exporting a Liveboard report. Filters specified here override any existing filters that are applied on the same columns in the Liveboard.
The override_filters value is a JSON array of filter objects, with each object targeting one column.
"override_filters": [
{ ... },
{ ... }
]
|
Important
|
|
Filter object fieldsπ
Each filter object in the JSON array has the following top-level fields:
| Field | Description | ||
|---|---|---|---|
| Name of the column to filter. The +
If there are multiple columns with the same name, you can use the
| ||
| Attribute or measure filter for columns with data type other than | ||
| Date filter definition for the columns with | ||
| Boolean. When |
Date filter parametersπ
For date_filter objects, use the following table attributes as needed:
| Field | Description | ||
|---|---|---|---|
| String. Valid values for fixed date filters include:
Valid values for rolling date filters include:
The following types are not supported:
| ||
| For rolling date filters such as Valid values for
| ||
| For | ||
| Comparison operator. Valid values depend on
| ||
| Period count. Required when | ||
| Required when | ||
| Required for the | ||
| Four-digit year as a string (for example, | ||
| Quarter identifier. Required for | ||
| Name of the month in uppercase. Required for |
Examplesπ
Generic filter exampleπ
"override_filters":[
{
"column_name":"Item type",
"generic_filter":{
"op":"EQ",
"values":[
"Jackets",
"Bags"
]
},
"negate":false
},
{
"column_name":"Region",
"generic_filter":{
"op":"IN",
"values":[
"west",
"midwest"
]
},
"negate":false
}
]
Combining date and attribute filtersπ
"override_filters": [
{
"column_name": "Order Date",
"date_filter": {
"type": "LAST_N_PERIOD",
"datePeriod": "MONTH",
"number": 3,
"op": "EQ"
}
},
{
"column_name": "Region",
"generic_filter": {
"op": "IN",
"values": ["West", "East"]
}
}
]
Negated filter exampleπ
"override_filters":[
{
"column_name": "Order Date",
"negate": true,
"date_filter": {
"type": "QUARTER_YEAR",
"op": "EQ",
"quarter_name": "Q1",
"year_name": "2026"
}
}]
Datetime data type exampleπ
"override_filters":[
{
"column_name":"Commit Date",
"date_filter":{
"datePeriod":"HOUR",
"number":3,
"type":"LAST_N_PERIOD",
"op":"EQ"
}
}
]
Date filter examplesπ
Refer to the following table for examples of JSON object for date filters:
| Date filter type | Example |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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",
oper: "EQ",
values: [] // set an empty array to clear filters
}]
});
|
Note
|
|
Additional resourcesπ
Refer to the following documentation for more information: