Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JAnder
Helper I
Helper I

Get name of visual a user clicked on with JS

Is there a way to retrieve the name of a visual on a report from a user click. I know i can call `report.getPages()` and then on a page do `page.getVisuals()` but ideally i would like to just pick up the visual name from a click, maybe a custom context menu option that could then pass it as a parameter to a function

 

To clarify the Playground shows the below code, but it does not show you how to get the VisualContainer4 value. That code assumes you know the visual name....

 

try {
    const pages = await report.getPages();

    // Retrieve 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 filters = await visual.getFilters();
    console.log(filters);
}
catch (errors) {
    console.log(errors);
}
1 ACCEPTED SOLUTION
JAnder
Helper I
Helper I

In case anyone looks at this in the future, you can get the visual name throught the event parameter.

 

there is a visualClicked event you can subscribe to which then provides the visual details including the name.

https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/handle-events#events-and-their-res...

View solution in original post

1 REPLY 1
JAnder
Helper I
Helper I

In case anyone looks at this in the future, you can get the visual name throught the event parameter.

 

there is a visualClicked event you can subscribe to which then provides the visual details including the name.

https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/handle-events#events-and-their-res...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.