# Embedded Power BI - Form

## Use Case

Hi, How are you?

Thank you for your reading. Yesterday, I got a reporting requirement from the client.

&#x20;  I was thrilled when they wanted to know **how we could make the 360 Customer view more insightful**. And I told them we could make the Power BI tool with more data visualization, more analytics to create a comprehensive and engaging report that would reveal the customer's 360 view.&#x20;

&#x20;  So, I designed a sample Power BI report that displays the customer's demographics, loan and contract details, and customer care data. Then, I embedded this Power BI in the main form of the table. The Power BI report will be set as the filter by the current customer.\
&#x20;   Creating and displaying a visualization in the Main form using OOB components in Dataverse is very challenging. That's why I opted for the Embedded Power BI solution. :relaxed:

## Embedded Power BI report on Form

{% hint style="success" %}
Microsoft reference link: [Embed a Power BI report in a model-driven app main form](https://learn.microsoft.com/en-us/power-apps/maker/model-driven-apps/embed-powerbi-report-in-system-form)   &#x20;
{% endhint %}

My steps below and I used the app [**Power BI Embedder**](https://www.xrmtoolbox.com/plugins/Fic.XTB.PowerBiEmbedder/) in XrmToolbox to embed the Power BI report in the Main form.

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FKifEhn5stDfzmRy3lePb%2Fimage.png?alt=media&#x26;token=7ad24cd9-c9c2-479c-b280-c974d27581da" alt=""><figcaption><p>Involved Steps</p></figcaption></figure>

&#x20;  For instance, I have a report called **"FE\_Poc" -** that displays the customer's demographics, loan and contract details, and customer care data. I will embed this report in the Main form of the **Contact** table. The report will be **filtered** by **CustomerID** (a field on the Contact table).

### 1.1 Add filtering for the Power BI report

In the report, expand the **Filter** **>>** then add the field **CustomerID** under the section **"Filter on all pages" >>** then Save and Public report to Power BI Service.

{% hint style="info" %}
With this filtering, all pages of this report will be filtered by **CustomerID.**
{% endhint %}

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FIhnCMGnmxlwCFqJLd8IL%2Fimage.png?alt=media&#x26;token=269a7bde-760a-43d3-8323-2c8f20d97779" alt=""><figcaption><p>Add filtering for PwBI report</p></figcaption></figure>

The next step, I opened my **Solution** >> opened main form **Contact:**

* I added a new tab called **Power BI**&#x20;
* Then, I added a new section **FE\_Poc** in this tab.

I will embed the Power BI report into the section **FE\_Poc** under the **Power BI** tab.

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FmJ8oqaOUGL0HQ3vvYneH%2Fimage.png?alt=media&#x26;token=c2ecc57a-e290-4a18-aba8-9226fd52539b" alt=""><figcaption><p>Tab &#x26; Section for embedded Power BI</p></figcaption></figure>

### 1.2 Using XrmToolbox to embed the Power BI report

Now, open the [**XrmToolbox**](https://www.xrmtoolbox.com/) >> then use the app [**Power BI Embedder**](https://www.xrmtoolbox.com/plugins/Fic.XTB.PowerBiEmbedder/)**.**

Firstly, I need to find the **Group ID** and **Report ID** of the Power BI report **"FE\_Poc"** for the configuration in the XrmToolBox

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FiOVtC4DMeMZhQFR8TTaL%2Fimage.png?alt=media&#x26;token=e52411b9-e2b7-4ba0-ab72-7038c1e21b4d" alt=""><figcaption><p>How to find Group ID and Report ID</p></figcaption></figure>

Configuration on the app **Power BI Embedder:**

1. **Target** section:
   * *Entity*: choose entity **Contact**
   * *Form*: choose the main form needed to embed the Power BI report
   * *Tab*: choose the tab on the main form
   * *Section*: chose section on the main form
2. **Power BI Config** section:
   * *Method:* set default value - ***Manual***
   * *Group ID:* input the Group ID value of the Power BI report (above)\
     My sample: *<mark style="color:red;">52b0871f-948e-41d8-97cb-0375566b7dd5</mark>*
   * *Report ID:* input the Group ID value of  the Power BI report (about)\
     My sample: *<mark style="color:red;">6781e570-7f4d-400a-8231-c5ab898621a7</mark>*
   * *Page*: input the value [https://app.powerbi.com/reportEmbed?reportId=](https://app.powerbi.com/reportEmbed?reportId=6781e570-7f4d-400a-8231-c5ab898621a7)***\[\[ReportID]]***\
     Sample: My Report ID = *<mark style="color:red;">6781e570-7f4d-400a-8231-c5ab898621a7</mark>*\
     \&#xNAN;***-> Page:*** [https://app.powerbi.com/reportEmbed?reportId=](https://app.powerbi.com/reportEmbed?reportId=6781e570-7f4d-400a-8231-c5ab898621a7)*<mark style="color:red;">6781e570-7f4d-400a-8231-c5ab898621a7</mark>*
   * *URL*: input the value [*https://app.powerbi.com*](https://app.powerbi.com)\
     *---*
   * Tick the field **Filter** -> to enable pre-filtering for the Power BI report. \
     The filtering configuration is below:
     * *<mark style="color:green;">PBI Table:</mark>* select Power BI Dataset which contains the field **"Customer ID"&#x20;*****(used for pre-filtering).***
     * *<mark style="color:green;">PBI Column</mark>*: select a column in the Power BI Dataset used for filtering (in Filter Pane).
     * *<mark style="color:green;">CDS Field:</mark>* select a column of the table **Contact** in Dataverse. This column will be used to filter the Power BI report.

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FcAZwrlDCDEiRadv9Sd7h%2Fimage.png?alt=media&#x26;token=e9c453ca-52d3-4d79-947f-f3c9827a6813" alt=""><figcaption><p>Configuration - Power BI Embedder - Publish</p></figcaption></figure>

Finally, just click **Publish Report** to finish and wait.... :tada:

## Checking now\...

Open a Contact - **A Nguyễn Văn (CustomerID = C000001)** -> The Customer ID auto filterred.

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FUM8j5ceCKfPvOiU8xBtG%2Fimage.png?alt=media&#x26;token=cbde9487-c1e0-4c9e-908f-e9af9c7cf482" alt=""><figcaption><p>Check first contact</p></figcaption></figure>

... and I check for another contact...

<figure><img src="https://4233060750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjhtQupP7ACZVtv3cCNCr%2Fuploads%2FWrV89Jk40np6q6Qtgbof%2F_Embedded_PowerBI_onForm.gif?alt=media&#x26;token=7a618d2d-3bc8-4fad-98a5-b025a485e592" alt=""><figcaption><p>Live check</p></figcaption></figure>

Yeah... with XrmToolbox, embedded the Power BI report so easily. \
Thank **XrmToolbox**, thanks **Ivan Ficko** author of Power BI Embedder app.&#x20;

Thank you and hoping well... :tada:\
\&#xNAN;**\[NTD]yns.asia**                                                                                                                         &#x20;
