Hi everyone,
I cannot been able to get visual filters from the "Sample Report" example on https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html
For example, i filtered for "Manufacturer" field selecting only "Barba" value, then i tried the given code:
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Get a reference to the embedded report.
report = powerbi.get(embedContainer);
// Retrieve the page collection and get the visuals for the first page.
try {
const pages = await report.getPages();
// Retrieve active page.
var activePage = pages.filter(function (page) {
return page.isActive
})[0];
const visuals = await activePage.getVisuals();
// Retrieve the target visual.
var visual = visuals.filter(function (visual) {
return visual.name == "VisualContainer4";
})[0];
const filters = await visual.getFilters();
Log.log(filters);
}
catch (errors) {
Log.log(errors);
}
and got this JSON as response:
> Json Object
[
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "Product",
"column": "Category"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "Product",
"column": "Product"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "SalesFact",
"measure": "@Indicator01"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "SalesFact",
"measure": "#Space02"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "SalesFact",
"measure": "#Space01"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "SalesFact",
"measure": "@Indicator02"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "Date",
"column": "Running Year"
},
"filterType": 1,
"operator": "In",
"values": [
1
],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#basic",
"target": {
"table": "Product",
"column": "Segment"
},
"filterType": 1,
"operator": "In",
"values": [
"Convenience",
"Moderation"
],
"requireSingleSelection": false
},
{
"$schema": "
http://powerbi.com/product/schema#advanced",
"target": {
"table": "SalesFact",
"measure": "Total Category Volume"
},
"filterType": 0,
"logicalOperator": "And",
"conditions": [
{
"operator": "IsNotBlank"
}
]
}
]
why i can't see the filter i made?
Thank you