> ## Documentation Index
> Fetch the complete documentation index at: https://ai-kb.automationanywhere.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Power BI Toolkit

> Connect Power BI to EKB agents and workflows to explore workspaces, reports, dashboards, datasets, and run DAX queries.

The Microsoft Power BI toolkit connects a Power BI account to EKB using OAuth and lets agents and workflows list workspaces, reports, dashboards, and datasets, retrieve dataset schemas, execute DAX queries, and trigger dataset refreshes. The toolkit runs with the connected user's Power BI permissions and does not elevate access beyond what that account can see.

## Prerequisites

* A Microsoft account with access to Power BI workspaces, reports, and semantic models you intend to use.
* At least Viewer access to a Power BI workspace.
* An EKB project where you can configure an agent or workflow.
* Your organization's Microsoft Entra administrator may need to approve the app's requested Power BI delegated permissions before the OAuth connection can complete.

<Warning>
  The toolkit runs with the connected user's Power BI permissions. It does not grant access beyond what that account can see in Power BI. Never include tokens, client secrets, or credential values in workflow inputs, prompts, screenshots, tickets, or documentation.
</Warning>

## Setup

<Steps>
  <Step title="Open an agent or workflow in EKB">
    Create or open an agent or workflow in EKB, then add the **Microsoft Power BI** toolkit.
  </Step>

  <Step title="Connect with Microsoft">
    When prompted, select **Connect with Microsoft Power BI** and sign in with the Microsoft account that has access to the Power BI workspaces, reports, and semantic models you need.
  </Step>

  <Step title="Accept permissions">
    Review and accept the requested permissions. If your organization requires administrator approval, ask your Microsoft Entra administrator to approve the app's delegated Power BI permissions before proceeding.
  </Step>

  <Step title="Confirm the connection">
    Run **List Workspaces** to confirm the connection is working and to obtain workspace IDs for use in subsequent actions.
  </Step>
</Steps>

## Available tools

### Discovery

| Tool                | Description                                                                                                                |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| **List Workspaces** | Lists the Power BI workspaces accessible to the connected user. Returns workspace IDs for use in other actions.            |
| **List Reports**    | Lists reports in a selected workspace. Omit workspace ID to list reports in My Workspace.                                  |
| **List Dashboards** | Lists dashboards in a selected workspace. Omit workspace ID for My Workspace.                                              |
| **List Datasets**   | Lists datasets (semantic models) in a selected workspace. Returns dataset IDs for use in schema, DAX, and refresh actions. |

### Data Exploration

| Tool                   | Description                                                                                                                                       |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Get Dataset Schema** | Returns the tables and columns available in a dataset or semantic model. Run this before authoring a DAX query to confirm table and column names. |
| **Execute DAX Query**  | Runs a DAX query against a dataset or semantic model and returns the results.                                                                     |

### Refresh Management

| Tool                    | Description                                                                                                                           |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **Refresh Dataset**     | Triggers a dataset refresh. Refresh requires write or refresh rights on the semantic model.                                           |
| **Get Refresh History** | Returns recent refresh records for a dataset. Use this to check whether the latest refresh completed before publishing a report link. |

## Recommended workflow

Start with **List Workspaces** → **List Datasets** (using a workspace ID) → **Get Dataset Schema** → **Execute DAX Query**. This sequence makes the available model and its table and column names visible before you write a query.

## Use cases

* Return the top revenue regions from a Power BI semantic model using a DAX query, then include the results in a Slack notification or report summary.
* Trigger a dataset refresh after an upstream data-load workflow completes, then use **Get Refresh History** to confirm success before publishing a report link.
* Let an agent list workspaces and reports, then surface a report URL to a stakeholder on request.
* Check the latest refresh status of a scheduled dataset before a downstream workflow depends on fresh data.

## Troubleshooting

| Symptom                              | Likely cause                                                                                             | Fix                                                                                                                                          |
| ------------------------------------ | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Admin approval required              | Your Microsoft Entra tenant requires administrator consent for the app's Power BI delegated permissions. | Ask your Microsoft Entra administrator to grant consent for the app registration.                                                            |
| No workspaces returned               | The connected account has no workspace access, or you are signed into the wrong Microsoft account.       | Confirm you are signed into the intended account and have at least Viewer access to a Power BI workspace.                                    |
| `401 Unauthorized`                   | The OAuth token has expired or been revoked, or the app registration configuration is invalid.           | Reconnect the toolkit. If the problem persists, contact an EKB administrator to check the OAuth app's client secret expiry and redirect URI. |
| `403 Forbidden`                      | The connected user lacks permission for the requested action at the workspace, dataset, or tenant level. | Ask the workspace or tenant administrator to grant the required permission. Dataset refresh requires write or refresh rights.                |
| Dataset schema or DAX action fails   | Incorrect workspace or dataset ID, insufficient permissions, or an invalid DAX expression.               | Run **List Datasets** to confirm the dataset ID, run **Get Dataset Schema** to verify table and column names, then correct the query.        |
| Refresh starts but does not complete | The semantic model's data source credentials, gateway, capacity, or refresh policy has a problem.        | Check **Get Refresh History** for the detailed failure reason and resolve it in the Power BI service.                                        |
| Connection expired                   | The OAuth token could not be refreshed automatically.                                                    | Reconnect the Microsoft Power BI toolkit. If the problem recurs, contact an EKB administrator to check the OAuth configuration.              |
