Search code examples
powerbi-embedded

Is there any way to print details of data when I click on it?


On my embedded report which has multiple visuals containing data, I want something like when I click on any data (for ex. a section in pie chart, a row in a table etc.), it should show me things like the visual name, applied filters on it, page name, report id etc.

Is it feasible? If yes, then how?


Solution

  • Power BI Embedded has Event Handlers to provide data on such events.

    You can follow below code snippets to get visual's data when clicked:

    1. Get a reference to the HTML element that contains the embedded report:
    const embedContainer = $('#embedContainer')[0];
    
    1. Embed the report:
    const report = powerbi.embed(embedContainer, embedConfig);
    
    1. Use "dataSelected" event handler to retrieve event details:
    report.on("dataSelected", function (event) {
    var data = event.detail;
    console.log(data);
    });
    

    The data object will contain the properties of your report and the selected visual.

    Please refer: How to handle events in a Power BI embedded analytics application | Microsoft Docs