Forum Discussion
Power BI Embedded: Problem using more than one filter on the same Embedded exporting all the Visuals
- 5 years ago
Hi, we solved it it was the [] characters when sending the filter.
I attach the solution!! Thanks!
function ReplaceFilters() {
//var a = $("#In1").val();
//var b = $("#In2").val();
const filterList = [{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "tCalendarioNestleN",
column: "SemanaNestle"
},
logicalOperator: "And",
conditions: [{
operator: "GreaterThanOrEqual",
value: 1
}, {
operator: "LessThanOrEqual",
value: 5
}]
},
{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "tProductos",
column: "cveCategoria"
},
operator: "In",
values: ["PURINA"]
}];var embedContainerPortafolio = $('#TendenciaSOut')[0];
var reportPortafolio = powerbi.get(embedContainerPortafolio); // Replace all report's filters.try {
reportPortafolio.setFilters( filterList);
// reportPortafolio.setFilters([filterList]); this was the one you sent us.
} catch (errors) {
console.log(errors);
}
/* catch (errors) { console.log(errors); }*/
}
HI Hugo_Gallardo,
I found you define multiple functions with filter structures to apply filters effect to your report, so I recommend you to transform them into one const variable and use it to set/update filters.
function ReplaceFilters() {
var a = $("#In1").val();
var b = $("#In2").val();
const filterList = [{
$schema: "http: //powerbi.com/product/schema#basic",
target: {
table: "tCalendarioNestleN",
column: "SemanaNestle"
},
logicalOperator: "And",
conditions: [
{
operator: "GreaterThanOrEqual",
value: a
},
{
operator: "LessThanOrEqual",
value: b
}
]
}, {
$schema: "http: //powerbi.com/product/schema#basic",
target: {
table: "tProductos",
column: "cveCategoria"
},
operator: "In",
values: ["SP"]
}];
var embedContainerPortafolio = $('#ChartFR')[0];
var reportPortafolio = powerbi.get(embedContainerPortafolio);
// Replace all report's filters.
try {
reportPortafolio.updateFilters(models.FiltersOperations.ReplaceAll, [filterList]);
} catch (errors) {
console.log(errors);
}
}
Power BI Playground - Developer Sandbox
Regards,
Xiaoxin Sheng
I get the following error
powerbi.min.js:4 Uncaught TypeError: Cannot read property 'powerBiEmbed' of undefined
at t.get (powerbi.min.js:4)
at ReplaceFilters1 (SellOut:2339)
at HTMLButtonElement.onclick (SellOut:1)
t.get @ powerbi.min.js:4
ReplaceFilters1 @ SellOut:2339
onclick @ SellOut:1
- Hugo_Gallardo5 years agoHelper I
FUNCTION }
var reportPortafolio = powerbi.get(embedContainerPortafolio); // Replace all report's filters.
try { reportPortafolio.updateFilters(models.FiltersOperations.ReplaceAll, [filterList]); } catch (errors) { console.log(errors); }
}- Anonymous5 years agoNot applicable
Hi Hugo_Gallardo,
If you modify the code to use setFilters function instead of the updateFitlers, did this issue still appears?
// Replace all report's filters. try { reportPortafolio.setFilters([filterList]); } catch (errors) { console.log(errors); }Regards,
Xiaoxin Sheng
- Hugo_Gallardo5 years agoHelper I
I am not using embedContainerPortafolio because I am using every visual embbed.
My actual function is
function ReplaceFilters() {
var a = $("#In1").val();
var b = $("#In2").val();
const filterList = [
{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "tCalendarioNestleN",
column: "SemanaNestle"
},
logicalOperator: "And",
conditions: [
{
operator: "GreaterThanOrEqual",
value: a
},
{
operator: "LessThanOrEqual",
value: b
}]
},
{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "tProductos",
column: "cveCategoria"
},
operator: "In", values: ["SP"]
}];
var GraficoUno = $('#TendenciaSOut')[0];
var reportVisual = powerbi.get(GraficoUno);
try { reportVisual.setFilters(models.FiltersOperations.ReplaceAll.FiltersOperations.ReplaceAll, [filterList]); }
catch (errors) { console.log(errors); }
}Do I just make an embedded zone as Portfolio? can you show me the link to that?