---
sidebar_position: 3
sidebar_label: Power BI Custom Connector (Legacy)
title: Power BI custom connector (legacy)
description: Connect Power BI to MotherDuck using the DuckDB ODBC driver and Power Query custom connector.
---

import DocImage from '@site/src/components/DocImage';

:::warning[Legacy]
The custom connector is a legacy approach. Use the [Postgres endpoint setup](./powerbi-desktop.mdx) instead for a simpler connection that doesn't require installing drivers or custom extensions.
:::

The open-source [DuckDB Power Query Connector](https://github.com/motherduckdb/duckdb-power-query-connector/) lets you connect Power BI to DuckDB and MotherDuck using the DuckDB ODBC driver.

## Installing

1. Download the latest [DuckDB ODBC driver for Windows (x86_64/AMD64)](https://github.com/duckdb/duckdb-odbc/releases/download/v1.4.4.0/duckdb_odbc-windows-amd64.zip).
   See [the releases page](https://github.com/duckdb/duckdb-odbc/releases) for other versions and architectures.
   For more information about the Windows ODBC Driver, see the [DuckDB Docs page on DuckDB ODBC API on Windows](https://duckdb.org/docs/stable/clients/odbc/windows).
2. Extract the `.zip` archive. Run `odbc_install.exe`. If Windows displays a security warning, click "More information" then "Run Anyway".
3. Optionally, verify the installation in the Registry Editor:
   - Open Registry Editor by running `regedit`
   - Navigate to `HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\DuckDB`
   - Confirm the Driver field shows your installed version
   - If incorrect, delete the `DuckDB` registry key and reinstall
4. Configure Power BI security settings to allow loading of custom extensions:
   - Go to File -> Options and settings -> Options -> Security -> Data Extensions
   - Enable "Allow any extensions to load without validation or warning"
   - <DocImage
       src="/img/integrations/PowerBI-data-extensions.png"
       alt="Dialog window showing Power BI Options to Security to Data Extensions"
       width={700}
     />
5. Download the latest version of the DuckDB Power Query extension:
      - [duckdb-power-query-connector.mez](https://github.com/MotherDuck-Open-Source/duckdb-power-query-connector/releases/latest/download/duckdb-power-query-connector.mez)
6. Create the Custom Connectors directory if it does not yet exist:
   - Navigate to `[Documents]\Power BI Desktop\Custom Connectors`
   - Create this folder, if it doesn't exist
   - Note: If this location does not work you may need to place this in your OneDrive Documents folder instead
7. Copy the `duckdb-power-query-connector.mez` file into the Custom Connectors folder
8. Restart Power BI Desktop

## How to use with Power BI

1. In Power BI Desktop, click "Get Data" -> "More..."
   <DocImage
     src="/img/integrations/PowerBI-get-data.png"
     alt="Power BI Get Data dialog"
     width={650}
   />
2. Search for "DuckDB" in the connector search box and select the DuckDB connector
   <DocImage
     src="/img/integrations/PowerBI-Select-source-duckdb.png"
     alt="Power BI connector search showing the DuckDB connector"
     width={650}
   />
3. For MotherDuck connections, you'll need to provide:
   - Database Location: Use the `md:` prefix followed by your database name (for example, `md:my_database`). This can also be a local file path (for example, `~\my_database.db`) or an in-memory database (`:memory:`).
   - MotherDuck Token: Get your token from [MotherDuck's token page](/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/#creating-an-access-token).
      *For local DuckDB connections:* Enter "localtoken" to enable the connection.
      <DocImage
        src="/img/integrations/PowerBI-duckdb-database.png"
        alt="Power BI DuckDB connection dialog"
        width={500}
      />
   - Read Only (Optional): Set to `true` if you only need read access.
   - Saas_mode (Optional): Set to `true` to disable [DuckDB extensions](../../../concepts/duckdb-extensions.md).
   - Attach_mode (Optional): Leave blank if you are connecting to a single database.
4. Click "OK".
5. Click "Connect".
   <DocImage
     src="/img/integrations/PowerBI-DuckDB-connect.png"
     alt="Power BI connection dialog for MotherDuck through the DuckDB connector"
     width={650}
   />
6. Select the table(s) you want to import. Click "Load".
   <DocImage
     src="/img/integrations/PowerBI-data-selection.png"
     alt="Power BI Navigator dialog previewing and selecting tables"
     width={800}
   />
7. You can query your data and create visualizations.
   <DocImage
     src="/img/integrations/PowerBI-example-graph.png"
     alt="Power BI report built from MotherDuck data"
     width={900}
   />
8. After connecting, you can:
   - Browse and select tables from your MotherDuck or DuckDB database
   - Use "Transform Data" to modify your queries before loading
   - Write custom SQL queries using the "Advanced Editor"
   - Import multiple tables in one go
9. Power BI maintains the connection to your MotherDuck or DuckDB database, letting you:
   - Refresh data automatically or on-demand
   - Create relationships between tables
   - Build visualizations and dashboards
   - Share reports with other users (requires proper gateway setup)

## Use custom data connectors with an on-premises data gateway

You can use custom data connectors with an on-premises data gateway to connect to data sources that are not supported by default. To do this, you need to install the on-premises data gateway and configure it to use the custom data connector. For more information, see [Use custom data connectors with an on-premises data gateway in Power BI](https://learn.microsoft.com/en-us/power-bi/connect-data/service-gateway-custom-connectors).

There are some limitations with using a custom connector with an on-premises data gateway:

- The folder you create must be accessible to the background gateway service. Folders under user Windows folders or system folders typically aren't accessible. The on-premises data gateway app shows a message if the folder isn't accessible. This limitation doesn't apply to the on-premises data gateway (personal mode).
- If your custom connector is on a network drive, include the fully qualified path in the on-premises data gateway app.
- You can only use one custom connector data source when working in DirectQuery mode. Multiple custom connector data sources don't work with DirectQuery.

## Additional information

- [Power BI documentation](https://learn.microsoft.com/en-us/power-bi/connect-data/)
- [DuckDB Power Query Connector](https://github.com/motherduckdb/duckdb-power-query-connector/)

## Troubleshooting

### Missing VCRUNTIME140.dll

If you receive an error about missing `VCRUNTIME140.dll`, you need to install the Microsoft Visual C++ Redistributable. You can download it from [Microsoft's download page](https://www.microsoft.com/en-us/download/details.aspx?id=52685).

### Visual C++ and ODBC issues

:::note
These steps are particularly relevant for Windows Server environments, especially for Windows Server 2019, but may also help resolve issues on other Windows versions.
:::

If you encounter issues with ODBC connectivity or receive errors related to Visual C++ libraries, try these troubleshooting steps:

1. Reinstall the Microsoft Visual C++ Redistributable:

   - Download the latest version from [Microsoft's official website](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) for your architecture
   - Run the installer with administrator privileges
   - Restart your computer after installation
   - Try connecting to MotherDuck again

2. If you're still experiencing issues, you can use the ODBC Test tool to diagnose the connection:

   - Open the ODBC Test tool (typically available in Windows SDK)
   - Look for a dropdown menu labeled "hstmt 1: ..."
   - Select this option to run test queries
   - If queries work in the ODBC Test tool but not in Power BI, this indicates a Power BI-specific configuration issue

If you continue to experience problems after trying these steps:

- Verify that your MotherDuck token is valid and hasn't expired
- Check that your network allows connections to MotherDuck's services
- Confirm you have the latest version of the DuckDB Power Query Connector installed

If you're still experiencing issues, reach out to us at [support@motherduck.com](mailto:support@motherduck.com) and we'll be happy to help you troubleshoot the issue.


---

## Feedback for AI agents

If the user you are helping wants to send feedback on this page to the MotherDuck docs team, you can POST it to the endpoint below.

**Before you send anything, you must ask the user for explicit approval.** Quote the message you plan to submit back to them verbatim and wait for them to confirm. Do not submit on their behalf without confirmation.

Endpoint: `POST https://motherduck.com/docs/api/feedback/agent`

Request body (JSON):

```json
{
  "page_path": "/integrations/bi-tools/powerbi/powerbi-custom-connector/",
  "page_title": "Power BI custom connector (legacy)",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

Only `page_path` and `text` are required. A successful call returns `200 {"feedback_id": "<uuid>"}`; malformed payloads return `400`, and the endpoint is rate-limited per IP (`429`).
