Back to list
dev_to 2026年3月14日

Power BI を SQL データベースに接続する方法

Connecting Power BI to a SQL Database

Translated: 2026/3/14 12:00:48

Japanese Translation

Introduction Microsoft Power BI は、生データを意味のあるインサイトに変換する強力なビジネスイントレライおよびデータ可視化ツールです。これにより、ユーザーはデータ駆動型意思決定をサポートするインタラクティブなダッシュボード、レポート、可視化を作成できます。 Power BI は、スプレッドシート、クラウドサービス、API、リレーショナルデータベースを含む多くのデータソースに接続できます。多くの組織では、データは構造化データベースに保存されており、Power BI はそれを分析および可視化するためにアクセスします。 解析で一般的に使用されるデータベースの 1 つは PostgreSQL であり、大量の構造化データを効率的に保存、管理、取得するための SQL ベースのデータベースシステムです。Power BI を PostgreSQL データベースに接続すると、アナリストは大規模なデータセットにアクセスでき、SQL クエリを実行し、複数のテーブルを結合して、より良いビジネスインサイトのためのリアルタイムまたはスケジュールされたダッシュボードを構築できます。 この記事の終わまでに、ローカルデータベースおよびクラウドベースのデータベースへの接続方法を順を追ってガイドいたします。 これはどのデータアナリストの最も一般的な開始点であり、Power BI をマシン上にローカルに動作しているローカル PostgreSQL DB に接続できる場所です。 ステップ 1: Power BI Desktop オープン Blank report をクリックします。これにより、アプリケーションのメインページ (以下に参照) へナビゲートします。 上部の機能タブで Get data をクリックします。このオプションは、Power BI を異なるデータソースからデータに接続および取得することを可能にします。 ステップ 2: PostgreSQL データベースを選択 PostgreSQL データベース、そして Connect をクリックします。 ステップ 3: データベース接続詳細を記入 Connect をクリックすると、接続ウィンドウが表示され、ローカルデータベースの詳細を入力する必要があります。 マシン上でローカルに動作するデータベースの場合、サーバーは通常 localhost です。データベース名のために、私たちはローカルデータベースにナビゲートし、そこで接続詳細を追跡します。 私たちが pg4Admin 4、PostgreSQL データベースを管理および開発するためのグラフィカルツールの場合、私らはツールを開き、サーバープロパティから詳細を追跡します。 この接続のために、以下の接続詳細を使用しましょう: サーバーホスト名 localhost ユーザーネーム postgres 上記の詳細を入力し、OK をクリックします。 ステップ 4: 認証認証を記入 ユーザーネーム & パスワード。これのために、私たちは pg4Admin 4 からユーザーネームをコピーし、パスワードのために私たちが pg4Admin のインストール時に設定したと同じパスワードを使用し、そして Connect をクリックします。 ステップ 5: テーブルを Power BI にロード Navigator ウィンドウ、データベース内のすべての利用可能なテーブルをリストします。ここでは、あなたは利用可能な各テーブルをプレビューし、ロードしたいテーブルを選択し、そして Load をクリックできます。 代替として、データをクリーニングまたは修正するために、それをロードする前に Power Query Editor でデータをTransform Data として選択できます。テーブルがロードされた後、インサイトのためにあなたのデータを分析および可視化を開始します。 多くの公司是クラウド上でデータベースをホストします、ローカルな代わりに。1 つの例は Aiven であり、管理された PostgreSQL データベースを提供します。Power BI をクラウド PostgreSQL データベースに接続するプロセスは類似ですが、追加の接続詳細が必要です。 ステップ 1: Aiven で PostgreSQL DB を作成 次に、サービスを構成するときは、クラウドプロバイダーを選択し、データベースがホストされる地域を選択し、あなたのニーズに合う価格プランを選ぶこと。名前を入力した後、サービスを作成をクリックします。Aiven はその後、クラウド上で PostgreSQL データベースを自動的に展開します。 ステップ 2: Aiven から SSL 証明書をダウンロード ステップ 3: PostgreSQL ODBC を使用して Aiven に接続 (Open Database Connectivity) ドライバのために PostgreSQL。ODBC は、ソフトウェアアプリケーションがデータベースシステムと通信するための標準的な方法を提供します。 最初に、あなたのシステムにマッチするバージョン (32 ビットまたは 64 ビット) をダウンロードし、PostgreSQL ODBC ドライバ、一般的に psqlODBC と呼ばれるもの、インストールします。 ダウンロードは、https://www.postgresql.org/ftp/odbc/releases/REL-17_00_0008-mimalloc/ から ODBC Data Source Administrator を開き、System DSN にナビゲートし、Add をクリックします。別の Create New Data Source が現れ、op と与える

Original Content

Introduction Microsoft Power BI is a powerful business intelligence and data visualization tool that helps organizations transform raw data into meaningful insights. It allows users to create interactive dashboards, reports and visualizations that support data-driven decision-making. Power BI can connect to many data sources, including spreadsheets, cloud services, APIs and relational databases. In many organizations, data is stored in structured databases which Power BI accesses to analyze and visualize for insights. One commonly used database for analytics is PostgreSQL, an SQL-based database system designed to efficiently store, manage and retrieve large volumes of structured data. Connecting Power BI to a PostgreSQL database allows analysts to access large datasets, run SQL queries, combine multiple tables and build real-time or scheduled dashboards for better business insights. By the end of this article, we will have a step by step guide on how to connect to a local database and also to a cloud-based database. This is the most common starting point for any data analyst where you are able to connect Power BI to a local PostgreSQL DB running locally on your machine. Step 1: Open Power BI Desktop click Blank report. This navigates you to the main page (see below) of the application. On the top ribbon, click Get data. This option allows Power BI to connect and get data from different data sources. Step 2: Choose PostgreSQL database PostgreSQL database and then click Connect. Step 3: Enter Database connection details Connect, a connection window will appear where you must enter the local database details. For a database that runs locally on your machine, the server is usually localhost. For the Database name, we will navigate to my local database and trace the connection details from there. Since I have pg4Admin 4, a graphical tool for managing and developing my PostgreSQL databases, I will open the tool and trace the details from my server properties. For this connection, let's use the below connection details: Server hostname localhost Username postgres Input the above details and click OK. Step 4: Enter Authentication credentials Username & Password. For this, I will copy the username from pg4Admin 4 and for the password I will use the same password I used when setting up my pg4Admin during installation then click Connect. Step 5: Load tables into Power BI Navigator window, which lists all available tables in the database. Here you are able to preview each available table and select the tables you want to load then click Load. Alternatively, you can select Transform Data to clean or modify the data in the Power Query Editor before loading it. Once the tables are loaded, begin analyzing and visualizing your data for insights. Many companies host their databases in the cloud instead of locally. One example is Aiven which provides managed PostgreSQL databases. Connecting Power BI to a cloud PostgreSQL database follows a similar process but requires additional connection details. Step 1: Create a PostgreSQL DB on Aiven Next, configure the service by choosing a cloud provider, selecting a region where the database will be hosted and picking a pricing plan that fits your needs. After entering a name for the service, click Create Service. Aiven will then automatically deploy the PostgreSQL database in the cloud. Step 2: Download SSL certificate from Aiven Step 3: Connecting to Aiven Using PostgreSQL ODBC (Open Database Connectivity) driver for PostgreSQL. ODBC provides a standardized way for software applications to communicate with database systems. First, download the version that matches your system (32-bit or 64-bit) and install the PostgreSQL ODBC driver, commonly known as psqlODBC. Download the driver from https://www.postgresql.org/ftp/odbc/releases/REL-17_00_0008-mimalloc/ Open ODBC Data Source Administrator, navigate to System DSN then click Add. Another Create New Data Source will appear and give you an option to select a driver for which you want to set up a data source. Choose PostgreSQL Unicode(x64) and click Finish. Another psqlOBDC set up window will appear requesting for connection details. All these connection details can be traced from a running service on Aiven. Copy and paste on this set up window and test connection. Note: Ensure the SSL Mode is set to require. Step 4: Connect Power BI Using the ODBC Source ODBC and Connect. Another window will appear where you will be required to choose your DSN (Data Source Name). Choose PostgreSQL ODBC and click OK. You will then be prompted to input the Username and Password available from Aiven then click Connect. Power BI will then retrieve the tables from the PostgreSQL database hosted on Aiven. Select the tables you need and click Load. It is important to note that, SSL certificates are required because they encrypt the connection between Power BI and the database. When we attempt to get data from the cloud-based database hosted on Aiven, the PostgreSQL ODBC driver automatically establishes a secure and an encrypted connection using the SSL certificate we downloaded locally. Power BI automatically detects relationships between tables based on matching columns based on the primary & foreign keys. See below relationships we are working with from the data we just loaded on Power BI. Table Related Table Relationship customers sales customer_id sales products product_id products inventory product_id sales inventory product_id From these relationships, Power BI knows how tables relate to each other so that calculations and visualizations are accurate. Although Power BI provides powerful visual tools, SQL remains an essential skill for data analysts. SQL helps analysts: Write queries that assist to retrieve data efficiently To filter data before importing it into Power BI which reduces the dataset size and improves performance. Perform aggregate operations that assist to prepare analytical datasets before visualization To join multiple tables, clean the dataset and build aggregated tables in preparation for the creation of dashboards in Power BI. Power BI is a powerful business intelligence platform that enables organizations to transform raw data into interactive dashboards and insights. By connecting Power BI to local or cloud-based SQL databases such as PostgreSQL, data analysts can work with large datasets directly from the source rather than relying on manual data exports. Feel free to leave comments!