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); }*/
}
FUNCTION }
var reportPortafolio = powerbi.get(embedContainerPortafolio); // Replace all report's filters.
try { reportPortafolio.updateFilters(models.FiltersOperations.ReplaceAll, [filterList]); } catch (errors) { console.log(errors); }
}
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?
- Hugo_Gallardo5 years agoHelper I
powerbi.min.js:4 Uncaught (in promise) [{…}]0: {message: "input must be an object"}length: 1[[Prototype]]: Array(0)
l @ powerbi.min.js:4
Promise.then (async)
s @ powerbi.min.js:4
(anonymous) @ powerbi.min.js:4
o @ powerbi.min.js:4
e.setFilters @ powerbi.min.js:4
ReplaceFilters @ SellOut:2430
onclick @ SellOut:669 - Hugo_Gallardo5 years agoHelper I
SellOut:599 Uncaught ReferenceError: filter1 is not defined
at HTMLButtonElement.onclic