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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
-Rem-
Frequent Visitor

Getting selected element in a Power BI report from API

I am looking to get what item has been selected in Power BI and to send that information to a program outside of Power BI.

Previously, I have done this in connection with PowerApps. Using PowerBIIntegration.Data, I was able to get information based on a visual selection in Power BI - such as which customer had been selected in a list. We have now decided to replace PowerApps with custom developed third party software for our particular use case. So now, instead of being able to select a customer in Power BI and have PowerApps be automatically pre-populated with information from this customer I need a way so I can still select a customer in Power BI but get the information to a different destination. I have researched the REST API PBI offers but I was unsuccesful. 

1 ACCEPTED SOLUTION
MattCalderwood
Responsive Resident
Responsive Resident

Hi @-Rem- 

if you are using the PowerBI Javascript API to perform the embedding - then you can use the 'Events' capability within reports.
https://github.com/microsoft/PowerBI-JavaScript/wiki/Handling-Events

Registering to the 'dataSelected' event will let your application handle selections that it is interested in.
It can a little bit fiddly to filter out the noise to find only the events you are interested in - but this technique is reliable and works very well.

Another possible option is to use the 'Commands' API -> https://github.com/Microsoft/PowerBI-JavaScript/wiki/Commands
This will let you extend the context/header menu on some visuals. You can then acces the datapoints that are currently 'in focus' and perform actions in your app that way.

Hope this helps.

View solution in original post

2 REPLIES 2
MattCalderwood
Responsive Resident
Responsive Resident

Hi @-Rem- 

if you are using the PowerBI Javascript API to perform the embedding - then you can use the 'Events' capability within reports.
https://github.com/microsoft/PowerBI-JavaScript/wiki/Handling-Events

Registering to the 'dataSelected' event will let your application handle selections that it is interested in.
It can a little bit fiddly to filter out the noise to find only the events you are interested in - but this technique is reliable and works very well.

Another possible option is to use the 'Commands' API -> https://github.com/Microsoft/PowerBI-JavaScript/wiki/Commands
This will let you extend the context/header menu on some visuals. You can then acces the datapoints that are currently 'in focus' and perform actions in your app that way.

Hope this helps.

Thank you very much, this looks like exactly the kind of reference I need. I only ever got the REST API which did not seem capable of solving the issue for me but this seems like it should be able to handle the job. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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