Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Seems like a simple thing to do but I'm not able for figure this one out.
I am embedding a visual (slicer), attaching an event handler for "selectionChanged" and just trying to get the values of the slicer.
let embedConfiguration = {
accessToken: psEmbedDetails.token.Token,
embedUrl: psEmbedDetails.embedUrl,
id: PageSectionWidget.PowerBIReport,
pageName: PageSectionWidget.PowerBIPage,
tokenType: models.TokenType.Embed,
type: 'visual',
slicers: [],
visualName: PageSectionWidget.PowerBIWidget,
permissions: models.Permissions.All,
viewMode: models.ViewMode.View,
filters: [basicFilterCustomer, basicFilterFurnace],
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: false
}
};
// Get a reference to the HTML element that contains the embedded report.
let embedContainer = $('#psw' + PageSectionWidget.PageSectionWidgetId)[0];
// Embed the visual.
let visual = powerbi.embed(embedContainer, embedConfiguration);
embeddedElements.push(visual);
visual.on("selectionChanged", function (event) {
console.log(event.detail);
});The details are blank for dataPoints and filters. I just want to get the slicer date range (start and end date)
Thanks for any help!
Hi @acarlson
The selectionChanged event is raised whenever the user is changing the selected visual. selectedItems is a list of all selected visuals when more than one is selected.
report: models.IReport
page: models.IPage
visual?: models.IVisual
selectedItems?: models.IVisual[]
For referece: Selector.SelectionChanged Event
You may refer to this offical blog to learn more details about selectionChanged.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Rico, thanks for the reply.
The selection changed event reference you gave seems to be for .net controls. I'm trying to get it through the power bi embedded javascript api. The timestamp slicer is an embedded visual, is it possible to get the selected items from within the javascript selectionChanged event?
This is what is returned from the event parameter
I tried using the getSlicerState() but that returns "getSlicerState is not a function" javascript error.
visual.on("selectionChanged", function (event) {
console.log(event);
let curV = powerbi.get(event.target);
curV.getSlicerState().then(slicerState => {
if (slicerState.filters.length > 0) filteredSlicers.push(slicerState)
})
});
Thanks!
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 4 | |
| 3 | |
| 2 |