# Configure the Power BI report

{% hint style="warning" %}
Before configuring the Power BI report, make sure you have data from your workstations in your log analytics workspace, and make sure the automation runbooks have run at least once. Without data, the kusto queries in the Power BI report will fail.
{% endhint %}

## Download

Download the Power BI report template from here:

{% embed url="<https://github.com/SMSAgentSoftware/MEM/blob/main/Software%20Updates%20Reporting%20Solution/Power%20BI%20template/Software%20Updates%20Compliance%20Report.pbit>" %}

## Configure the report

Using Power BI desktop, open the report template. Upon opening, you'll be prompted for the **workspace ID** of your log analytics workspace, and the **data retention period**. The latter is used to determine how far back in time the report queries will search for data.

Click **Load**.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FaMRDeZscfVQ1XXCTh5kd%2Fimage.png?alt=media&#x26;token=c14b2f4e-e827-4eb1-95f0-f07a6e0922fb" alt=""><figcaption></figcaption></figure>

If it's the first time you've connected to the log analytics workspace with Power BI, you'll be prompted for credentials. Choose **Organizational account**, sign in with your organizational account, and optionally select the level to apply to, or just accept the default. Click **Connect**.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FxZhGyca8O9y1UrFPvecz%2Fimage.png?alt=media&#x26;token=ffae898c-7fbb-4b4a-af35-76b427c47d5b" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
The account you sign in with should have at least the **Log Analytics Reader** role in the log analytics workspace.
{% endhint %}

After successful authentication, your report will run the kusto queries and load the data. If you have only just started collecting data from your workstations, some pages like the trend pages will not contain much data yet so will look better over time.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FBcUMSjG4uxLpyOBzGMOy%2Fimage.png?alt=media&#x26;token=efcf183a-090f-4b87-be04-4a6dc101ae60" alt=""><figcaption></figcaption></figure>

## Publishing to the Power BI service

If you wish to publish your report to the Power BI service and enable scheduled refresh, you will need a kind of service account that can be used to connect to the log analytics workspace. It should be an **Azure AD account** (either native or synced), should have at least the **Log Analytics Reader** role in the log analytics workspace, and the password should be infrequently changed.

Once you've published your report, locate the dataset and choose the **Settings** option.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2Fvr7bZacrjomYbDCCs4Xf%2Fimage.png?alt=media&#x26;token=6ca23e59-aea4-49a5-95ef-0e30110cca41" alt=""><figcaption></figcaption></figure>

Under **Data source credentials**, click **Edit credentials**.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FYlOhwETqWSS0uNAWQRZ1%2Fimage.png?alt=media&#x26;token=dcf30659-5741-4736-b370-b55ac423d035" alt=""><figcaption></figcaption></figure>

In the **Configure** window, choose **OAuth2** as the authentication method, and **Organizational** for the privacy level. Click **Sign in**, and sign in with your service account credentials.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FMjUi7O8auDEsRxTxIi79%2Fimage.png?alt=media&#x26;token=9b1b4606-ef8f-44f0-9994-5898c6ed5e0f" alt=""><figcaption></figcaption></figure>

You can then schedule a refresh and it will use these credentials to access the log analytics workspace to update the data.

{% hint style="info" %}
Ideally your refresh schedule should be synchronized with the schedule of your automation runbooks. Schedule a refresh maybe 10-15 minutes after each execution of the runbooks so that your report refreshes with the latest data as soon as its available.
{% endhint %}
