Use the filters-v2
Property to Pass Filters
You can use the filters-v2 property to programmatically
pass filter values to the HTML page where you embed Oracle Analytics content. This option passes filter values immediately to embedded content without reloading
the entire workbook. You can use this property to filter any type of data.
The filters-v2 property requires an array of
FilterControl JSON objects. You can obtain this array from a
workbook that contains existing filters of the types you want to embed. Or you can build
temporary filters in a workbook to generate the needed array, and after you copy the
array for embedding, you can delete the filter from the workbook.
For more information, see About Filters and Find the JSON Objects for the filters-v2 Property
The filters-v2 property can modify filters that
already exist in the workbook. If filters don't already exist in the workbook, this
property creates them.
[
{
"filterID": "8e24a0b0-04d3-48d3-9a0e-eb8fba77739e",
"columnID": "P4Brand",
"type": "saw:columnFilterControl",
"filterControlConfig": {
"_version": "1.0.8",
"settings": {
"filterModelClassName": "obitech-listfilter/listfilter.ListFilterModel",
"location": "filter_bar"
}
},
"address": 0.0001,
"formula": {
"expr": {
"children": [
],
"type": "sawx:sqlExpression",
"expression": "\"A - Sample Sales\".\"Products\".\"P4 Brand\""
}
},
"filterOperator": {
"op": "in"
},
"filterControlDefaultValues": {
"children": [
{
"text": "FunPod"
}
],
"type": "specificValue"
},
"filterControlSource": {
"type": "saw:fcSpecificChoices",
"filterControlChoices": {
"children": [
{
"value": {
"text": "FunPod"
}
}
]
}
}
},
{
"filterID": "ef6c6429-9d64-481e-9bf8-da0b334c2fb8",
"columnID": "T05PerNameYear",
"type": "saw:columnFilterControl",
"filterControlConfig": {
"_version": "1.0.8",
"settings": {
"filterModelClassName": "obitech-listfilter/listfilter.ListFilterModel",
"location": "filter_bar"
}
},
"address": 0.0001,
"formula": {
"expr": {
"children": [
],
"type": "sawx:sqlExpression",
"expression": "\"A - Sample Sales\".\"Time\".\"T05 Per Name Year\""
}
},
"filterOperator": {
"op": "in"
},
"filterControlDefaultValues": {
"children": [
{
"text": "2009"
},
{
"text": "2010"
}
],
"type": "specificValue"
},
"filterControlSource": {
"type": "saw:fcSpecificChoices",
"filterControlChoices": {
"children": [
{
"value": {
"text": "2009"
}
},
{
"value": {
"text": "2010"
}
}
]
}
}
}
]
Properties — Each filter object within the filters payload must contain the following properties:
-
filterID: Specifies a unique filter ID. For example,"8e24a0b0-04d3-48d3-9a0e-eb8fba77739e". -
address: Don't change this value. Use the value exactly as exported from the JSON you copied from the workbook. -
filterOperator: Specifies if the filter definition includes or excludes values. Useinto include values. UsenotInto exclude values. -
filterControlDefaultValues: Specifies the values used in the filter. These are the values the embedded content is filtered by. -
filterControlSource: Lists which of thefilterControlDefaultValuesare enabled, so all values that can be in the filter selection list. Note that a workbook's filter control can contain selected values that the workbook author disabled in the filter's value Selections list.For example, suppose you open the workbook in the Workbook editor and the column you're filtering is State and the selected filter values are AK, AL, and AR, where the AK value is disabled. The
filterControlDefaultValuescontains AL and AR (but not AK because it is disabled in the filter selection list), andfilterControlSourcecontains AK, AL, and AR.
This example shows how to create an expression filters on a measure value, so Limit Sales to less than 470000.
{
"filterID": "filter_sales",
"type": "saw:expressionFilterControl",
"label": {
"caption": {
"text": "Sales < 470000"
}
},
"expr": {
"type": "sawx:sql",
"expression": "XSA('<name>'.'Order Activity').\"Columns\".\"Sales\" < 470000"
},
"filterControlConfig": {
"_version": "1.0.8",
"settings": {
"filterModelClassName": "obitech-expressionfilter/expressionfilter.ExpressionFilterModel",
"location": "filter_bar"
}
}
}