DEV Community

Cover image for Publishing and Embedding Power BI Reports on the Web with IFrames
rosemutai
rosemutai

Posted on

Publishing and Embedding Power BI Reports on the Web with IFrames

Microsoft Power BI is a tool created by Microsoft to turn raw data into interactive insights.
The power of Microsoft Power BI lies in its ability to pull data from many sources, e.g., web, excel, clean the data and then create visuals that are easy to understand.

Key Components

  1. Power BI Desktop
  2. Power BI Service
  3. Power BI Mobile

Why Publish and Embed Reports?

After creating reports, there is need to share with your teammates and stakeholders. Hence the need to publish these reports.
Publishing to the web allows users to make reports publicly available and accessible on the internet creating interactive visuals that anyone with a URL can view without signing in.

Iframe

This is a HTML element used to embed another document or website within a web page,
You will use iframes to embed your reports on the web.

Syntax

<iframe src="url" title="description"></iframe>
Enter fullscreen mode Exit fullscreen mode

Use the height and width attributes to specify the size of the iframe. The height and width are specified in pixels by default.

Publishing Process

  • Create a report in Power BI Desktop
  • Publish it in Power BI Service
  • Generate an embedded code
  • Embed it in a website

Create a report in Power BI Desktop

First, start by building your report in Power BI Desktop.
You can include: KPI cards, trend visuals, category breakdowns, filters and slicers, etc.

Create a workspace

A workspace is a Power BI container for dashboards, reports, workbooks, datasets, and dataflows.

How to create a workspace
  1. Go to Power Bi Service: https://app.powerbi.com
    Power BI Home

  2. Click Workspaces in the left pane
    Click on Workspaces

  3. Select on +New workspace button
    +New workspace button

  4. Fill in the details: workspace name etc.
    Workspace details

Publish your Report

Once your report is ready we will upload it in the Power BI Service by following these steps:

  1. Open your report in Power BI Desktop
  2. Click Publish Power BI
  3. Sign into your account if not signed in
  4. Select your workspace

Select Workspace

  1. Click select button After publishing the report, it is now available online.

Generate the Embedded Code

How to generate the Embedded Code us

To generate an embedded code, open the report in your workspace and follow these steps:
1.** Click File** --> Embed Report --> Publish to Web
Embed Report

  1. Click Create Embed Code You will get code like this:
<iframe title="Electronics_Sales" width="1140" height="541.25" src="https://app.powerbi.com/reportEmbed?reportId=2bddbd15-9eb5-40c5-bea5-d196cd5f4ee2&autoAuth=true&ctid=c95984e8-6a70-4512-a440-1c79bca9cc37" frameborder="0" allowFullScreen="true"></iframe>
Enter fullscreen mode Exit fullscreen mode
  1. Copy the generated iframe code.

Embedding the report in a website

Now go to your favorite editor where your code is to embed the report.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Electronic Sales</title>
</head>
<body>
    <iframe title="Electronics_Sales" width="1140" height="541.25" 
        src="https://app.powerbi.com/reportEmbed?reportId=2bddbd15-9eb5-40c5-bea5-d196cd5f4ee2&autoAuth=true&ctid=c95984e8-6a70-4512-a440-1c79bca9cc37" 
        frameborder="0" allowFullScreen="true">
    </iframe>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Uploading on website

Test

Always test your report after embedding. You can check for things like:

  • Does the report load correctly?
  • Is it responsive on different screen sizes?

Conclusion

Publishing and embedding Power BI reports transforms your dashboards from static files into interactive and shareable web experiences.
Embedding enhances accessibility and presentations.

Top comments (0)