Forum Discussion
reshma
7 years agoNew Member
Filtering a report using query string parameters in the URL - not working as expected
We are passing the filter in the url. Our table name has spaces so replaced the spaces with '_x0020_' URL used : https://app.powerbi.com/groups/********/reports/***********/ReportSection?filt...
GilbertQ
7 years agoSuper User
Hi there
When you pass through a URL report filter, it filters the data on the report level and not at the slicer level. That is why you are getting it appearing like it is not working.
When you pass through a URL report filter, it filters the data on the report level and not at the slicer level. That is why you are getting it appearing like it is not working.
reshma
7 years agoNew Member
So, I should be using Slicer filter.
I am trying to set the Slicer filter using Javacript api. I am able to call setSlicerState function on visual. How to get reference to the visual by id and and set the slicer state?.
Here is my code
const filter = {
target: {
table: "Organisation Source",
column: "Organisation Description"
},
operator: "In",
values: ["Gippsland - AMHS"],
};
var embedConfiguration = {
type: drupalSettings.powerbi.display,
id: pbi_id,
embedUrl: pbi_embedUrl,
pageName: pbi_section,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
},
accessToken: drupalSettings.powerbi.accessToken,
};
var $reportContainer = $('#reportContainer');
if (pbi_embedUrl) {
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
report.on('rendered', () => {
report.getPages().then(pages => {
pages[0].getVisuals().then(function(visuals) { visuals[4].setSlicerState({filters:[filter]})});
});
});
}
else {
console.log('Embed Url is missing');
}
- GilbertQ7 years agoSuper UserHi there
To be totally honest I am not an embedded developer so I am not sure how this would work.
Hopefully someone who has that experience can help you.
You can possibly look at the Power BI Developer documents here: https://docs.microsoft.com/en-us/azure/power-bi-embedded/