Forum Discussion
Get all data from an slicer using powerbi-client js library, not only selected values
- Anonymous1 year ago
thank you
That's right I also tried this but it didn't work
I think powerbi library is not too much clear about what we can do as a developers. After several testing I found a function that can help to grab data from the slicer, it can be used to try to pre-validate what you want to send against slicer data and avoid having non existing values.
// Retrieve the page collection and get the visuals for the active page. try { const pages = await report.getPages(); // Retrieve the page that contain the visual. For the sample report it will be the active page let page = pages.filter(function (page) { return page.isActive })[0]; const visuals = await page.getVisuals(); // Retrieve the target visual. let visual = visuals.filter(function (visual) { return visual.name === "VisualContainer4"; })[0]; const result = await visual.exportData(models.ExportDataType.Summarized); console.log(result.data); } catch (errors) { console.log(errors); }
Hello Anonymous I tested what you recomended, but unfortunatelly the function getFilters() doesn't contain a definition for property values, so I wasn't able to access the values loaded in the dropd down slicer filter as you can see in the next screenshot.
That's right I also tried this but it didn't work
I think powerbi library is not too much clear about what we can do as a developers. After several testing I found a function that can help to grab data from the slicer, it can be used to try to pre-validate what you want to send against slicer data and avoid having non existing values.
// Retrieve the page collection and get the visuals for the active page.
try {
const pages = await report.getPages();
// Retrieve the page that contain the visual. For the sample report it will be the active page
let page = pages.filter(function (page) {
return page.isActive
})[0];
const visuals = await page.getVisuals();
// Retrieve the target visual.
let visual = visuals.filter(function (visual) {
return visual.name === "VisualContainer4";
})[0];
const result = await visual.exportData(models.ExportDataType.Summarized);
console.log(result.data);
}
catch (errors) {
console.log(errors);
}