PowerBI
10
 minute read

Power BI on Your Terms: Embed Reports Without Leaving Your Portal

Cristian Prifti
6 Aug
2024

Introduction

In previous articles we started talking about the importance of integrating Power BI reports with the Power Platform, while we looked at the integration with Power Automate. This time we will explore how to integrate the Power BI report in an internal portal or website, by leveraging the Website or portal option, which allows you to generate a simple embed URL.

NOTE
We will look at how to perform an URL embedding rather than a full-fledged embedding solution that provides more control and customizations, like an actual solution done through the Power BI Developer Playground.

Scenario

We aim to generate an embed URL, adding some additional parameters and see how we could use external inputs to filter the report while rendering it. This shows us that from an UX perspective, we could use such a method to avoid people navigating away from the context they were working in (e.g. an application, a portal etc.). Is it not annoying when you click on a button or link, and this opens a completely new tab?!

Generating the Base URL

We are going to choose the "efficient, not lazy" method, so we will open the desired report in the Power BI Service. Afterwards we will choose:

File ➡️ Embed report ➡️ Website or portal

Power BI Report in the Power BI Service
Power BI report in the Power BI Service

Unless you work with a developer that will add an iFrame, we are just going to copy the first link generated.

Power BI website or portal links pop-up window in the Power BI Service
Power BI website or portal links window

Now let's look at the code snippet we just copied:

https://app.powerbi.com/reportEmbed?
reportId=7ba5f9d1-75be-4016-911a-e077550004da&
autoAuth=true&
ctid=6ec206e4-1f91-4038-8cba-1481a39e5dc0&

Let's understand what the used parameters mean:

  • reportId:
    • This is a unique identifier (GUID) for the specific Power BI report that is being embedded or accessed. It tells Power BI which report to display when the URL is accessed.
    • In our case the reportId is 7ba5f9d1-75be-4016-911a-e077550004da.
  • ctid:
    • This stands for "Client Tenant ID" and is a GUID that identifies the Azure Active Directory (AAD) tenant under which the Power BI report resides. It is used to ensure that the report is accessed within the correct organizational context.
    • In our case the ctid is 6ec206e4-1f91-4038-8cba-1481a39e5dc0.
  • autoAuth:
    • This parameter indicates whether automatic authentication should be attempted when the URL is accessed. If autoAuth is set to true, Power BI tries to authenticate the user automatically using existing credentials or Single Sign-On (SSO) mechanisms (this parameter will always be present in real-life cases). From my testing, if set to false, or the parameter is omitted completely, the report will not load at all.

Let's perform a test. I am just going to use the link and open the report in a web browser.

Power BI Report with Default Embed URL
Power BI Report w. Default Embed URL

Considering that we are not in the Power BI Service context, this will just open the report. However, there are some aspects that I do not like:

  • Navigation Bar - We have on-screen buttons, hence this is not required.
  • Filter Pane - In the embedding context this will not be required.

Additional Parameters

Now this is the part where additional parameters will come to our rescue. These parameters are powerful tools for customizing the user experience and controlling how reports are presented and interacted with, especially in embedded scenarios.

navContentPaneEnabled

This parameter controls the visibility of the navigation pane which includes report pages. When set to false, the navigation pane is hidden, allowing for a cleaner view of the report. If set to true or omitted, the navigation pane will be visible, allowing users to navigate between different report pages.

URL Example:

1https://app.powerbi.com/reportEmbed?
2reportId=7ba5f9d1-75be-4016-911a-e077550004da&
3autoAuth=true&
4ctid=6ec206e4-1f91-4038-8cba-1481a39e5dc0&
5navContentPaneEnabled=false


Let's try it out:

Embedded Power BI report without page navigation bar
Embedded Power BI report w/o page navigation bar

filterPaneEnabled

This parameter determines whether the filter pane is visible to the user. If set to false, the filter pane is hidden, preventing users from altering filters directly from the filter pane. This is useful when you want to enforce certain filters without giving users the option to change them. Setting it to true or omitting it, makes the filter pane visible, allowing users to interact with and adjust filters.

URL Example:

https://app.powerbi.com/reportEmbed?
reportId=7ba5f9d1-75be-4016-911a-e077550004da&
autoAuth=true&
ctid=6ec206e4-1f91-4038-8cba-1481a39e5dc0&
navContentPaneEnabled=false&
filterPaneEnabled=false


Let's try it out:

Embedded Power BI report without filter pane
Embedded Power BI report w/o filter pane

groupId

The groupId parameter refers to the workspace (or group) where the Power BI report is located. This is especially relevant when embedding reports from different workspaces. It ensures that the report is accessed within the correct workspace context.

URL Example:

https://app.powerbi.com/reportEmbed?
reportId=7ba5f9d1-75be-4016-911a-e077550004da&
autoAuth=true&
ctid=6ec206e4-1f91-4038-8cba-1481a39e5dc0&
groupId=ffb44bc1-90cd-47d8-835a-b93ed7666fe7&
navContentPaneEnabled=false&
filterPaneEnabled=false


NOTE
Getting the Workspace ID can be easily done from the Power Service, as it will be the first parameter when accessing the workspace.
Power BI Service workspace ID position in the URL
Power BI Service Workspace ID

pageName

This parameter specifies the report page to display when the report is launched. It is especially useful for reports with multiple pages, as you can direct users to a specific page by default. The value for this parameter typically follows the format ReportSection<GUID>. The easiest way to identify the report page GUID is from the Power BI Service, when navigating to the respective page. The GUID will appear right after the report GUID.

Power BI report URL page name GUID position
Power BI report URL page name GUID


URL Example:

https://app.powerbi.com/reportEmbed?
reportId=7ba5f9d1-75be-4016-911a-e077550004da&
autoAuth=true&
ctid=6ec206e4-1f91-4038-8cba-1481a39e5dc0&
groupId=ffb44bc1-90cd-47d8-835a-b93ed7666fe7&
navContentPaneEnabled=false&
filterPaneEnabled=false&
pageName=ReportSectionbdcc727efec3d964ed1e


NOTE
If this parameter is omitted, the report will render with the active page from when the report was last edited/published.

Let's try it out:

Embedded Power BI with page navigation parameter
Embedded Power BI w. page navigation parameter

filter

The filter parameter enables you to apply filters to the report via the URL. This is useful for dynamically altering the data displayed based on the context in which the report is being viewed. The syntax generally follows the format filter=Table/Field eq 'Value', and you can combine multiple filters using logical operators like and, or, in etc.

Structure

The syntax generally follows the format filter=Table/Field eq 'Value'. Let's look at an example:

Filter Parameter Structure
Filter Parameter Structure

Now there are some aspects to be kept in mind:

  • Table and column names are case sensitive.
  • Filtering value supplied is not case sensitive
  • Column data type is important (see Data Type section below).
  • Special characters will be encoded (see URL Encoding section below).

Operators

For setting up the filters, we would first need to understand the OData operators that we can use. While OData has a broad range of operators, we will limit ourselves to 8 possible operators. For Power Automate developers these will sound familiar.

  • eq - Equals - Example: Customers/CustomerID  eq 'Customer_18'
  • ne - Does not Equal - Example: Customers/CustomerID  ne 'Customer_18'
  • and - And - Example: Customers/CustomerID  eq 'Customer_18' and Customers/CustomerID  eq 'Customer_19'
  • in - Including - Example: Customers/CustomerID  in ('Customer_18','Customer_19')
  • ge - Greater Than or Equal - Example: Calendar/Year ge 2023
  • gt - Greater Than - Example: Calendar/Year gt 2022
  • le - Less Than or Equal - Example: Calendar/Year le 2024
  • lt - Less Than - Example: Calendar/Year lt 2025

Data Types

An important aspect to be factored in is the actual data type of the column. There are 3 different data types that we talk about which are String, Number and Date. Depending on the data type, the structure of the supplied filter value will change.

NOTE
In this Microsoft Learn section, you can read more details into this topic.

Special Characters

When using special characters in table or column names within Power BI URL filters, they need to be encoded using a specific format. This involves prefixing the special character with an underscore, followed by "x", the four-digit Unicode, and another underscore. For example, a space would be encoded as x0020.

When using special characters in values most special characters are supported, but some might still require encoding.

When using URLs with special characters like a space for example (similarly to how we did this above in the operator table), those characters will be replaced automatically by the browser, however you could still follow a best practice to encode the full URL directly.


NOTE
You can find in this W3 documentation a complete list of escape characters used for encoding, but also more information about encoding in general.

Integrating Power BI reports directly into your internal portal or website not only enhances user experience but also streamlines access to crucial data. By leveraging embed URLs with customized parameters, you can keep your users engaged and focused within their workflow. Stay tuned for more insights on optimizing your Power BI solutions, and start embedding your reports today for a more seamless data experience!

Share this post