Power BI

The Power BI component is used to display an interactive Power BI dashboard in a field. To use this component Power BI must be setup in your trellispark environment, refer to the following articles to setup Power BI in your environment:

  1. Register Power BI application and define permissions
  2. Configure Azure Power BI Application
  3. Create Workspace
  4. Configure Workspace
  5. Create Gateway
  6. Configure Gateway
  7. Get Data for Power BI Report
  8. Transform Report Data
  9. Publish Report to Workspace

Component code

This first section contains some variables used for the component. Both the messageTemplate and ProgressMessage are used to update the user of what’s happening while the dashboard is being loaded, refreshed, and if there’s a problem loading the dashboard. PowerBIDashboard is where the dashboard will be embedded once it’s loaded.

OnParametersSetAsync()

This is the first method to be called after the component is initialized and anytime there’s an update to its parent component. This method is used to set some variable values and call the EmbedDashboard method. A guard mechanism is also integrated to ensure only one call is made to the PowerBI API per action.

EmbedDashboard()

This method is used to embed a dashboard on the page. It creates a DashboardInformation and PBIEmbedConfig object which are then used to make an API call to get the requested Power BI dashboard.

Once the dashboard has been retrieved a call is made to the pbi-client.js class in the UX-WASM-Components project, specifically the embedReport function using JS Interop. This function will embed the Power BI dashboard for the user to interact with.

Finally the UpdateRefreshInformation method is called. If there is a problem getting the Power BI dashboard or embedding it then a generic error message is displayed to the user and the API error is logged.

UpdateRefreshInformation(PBIEmbedConfig pbiEmbedConfig)

This method is used to update all the information displayed in the refresh popup window and determine if you’re allowed to trigger a manual refresh of the dataset based on the number of refreshes left in the daily quota. A dataset can be refreshed up to 8 times in a 24-hour period.

RefreshButtonSelected()

This method is called when the Refresh Dataset button is selected within the refresh dataset popup window. It’s purpose is the refresh the dashboards dataset by making an API call, then re-embed it by calling the EmbedDashboard method.

Updated on January 12, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment