powerbipowerbi-desktoppowerbi-custom-visualspower-bi-report-server

How to Display Detailed Information on Bar Chart Click in Power BI Report Server Using API Parameters?


I am using an API as a data source in Power BI Report Server. The API has two endpoints:

  1. GET localhost/peoples : Returns a complete list of people.
  2. GET localhost/peoples/{id} : Returns detailed information for a specific person based on their id.

In my Power BI Report Server report optimised, I have a bar chart that displays all people and their corresponding scores. What I would like to achieve is the following:

When a user clicks on a specific bar in the chart (representing a person), I want to display detailed information about that person in another visual (e.g., a table or another chart) by making a call to the second API endpoint ( localhost/peoples/{id} ) with the id of the selected person.

Questions:

What I've Tried:

I attempted to create a drillthrough action where clicking on a bar would pass the selected person's id to the second visual, but I couldn't figure out how to dynamically pass the id from the selected bar to the detailed API call (localhost/peoples/{id}).

What I Expected:

I expected to be able to click a bar representing a person in the chart and have the second visual (a table ) update to show detailed information about that selected person by calling the API with their id. Essentially, I want to dynamically filter the second visual based on the selected person from the first chart, using the API to fetch the detailed data.


Solution

  • Power BI Report Server does not natively support dynamic API calls from a visual interaction, but you can use query parameters combined with drillthrough and URL query filters to pass the selected person id from the bar chart to another visual.

    You’ll need to create query parameters that will hold the selected person ID to the second API endpoint.

    Then modify your data source for the detailed view visual (like a table) to include the API call that takes the selected personID :

      let
          baseUrl = "localhost/peoples/",
          personID = Parameters[personID],
          fullUrl = baseUrl & personID,
          response = Json.Document(Web.Contents(fullUrl))
      in
          response
    

    Add a second page for the detailed information use a table or chart where you display the detailed information using the data returned from the second API call. On the main report page with the bar chart, select the visual.

    In the Drillthrough field, add the personID or the unique identifier for each person. This way you can pass the selected id to the second page where the detailed API call happens.

    Then on the detailed information visual, filter the data based on the parameter where you use a measures or a calculated column to ensure that the visual only shows the data related to the selected personID.