How to load data into Microsoft Excel from a database using Power Query

How to load data into Microsoft Excel from a database using Power Query
How to load data into Microsoft Excel from a database using Power Query

The Microsoft Excel one of her first programs Microsoft . From its first versions, it had the ability to collaborate with software from other companies.

In this article we will explore how to connect Excel to any RDBMS and load data into its sheets.

The method we will use is the Power Query via ODBC.

For starters we'll have to make one ODBC Data Source on Windows.

How to load data into Microsoft Excel from a database using Power Query
1

User DSN - Add... - We select the Provider we want

How to load data into Microsoft Excel from a database using Power Query
2

We choose a name for ODBC and put the Server details

How to load data into Microsoft Excel from a database using Power Query
3

Details of the user who will connect to the database.

How to load data into Microsoft Excel from a database using Power Query
4

In excel now New Query – From Other Sources – From ODBC

How to load data into Microsoft Excel from a database using Power Query
5

*It is not necessary to use ODBC. We can choose From Database without using ODBC on the PC, but we will be limited to the RDBMS options currently provided by Excel.

How to load data into Microsoft Excel from a database using Power Query
6

* In case our RDBMS option is not there, we can choose from From other Sources The choise ODBC.

In the Data source name field we put the name with which we created the ODBC at the beginning. Also in the SQL statement field we can put SQL query for the data we want to load.

** In the case that the DSN box does not exist, we must write the DSN by hand in the Connection String field, e.g. DSN=sql .

How to load data into Microsoft Excel from a database using Power Query
7

Select Database and fill in username / password and connect.

How to load data into Microsoft Excel from a database using Power Query
8

Close & Load will load the data.

How to load data into Microsoft Excel from a database using Power Query
9

If we need to make any changes to the query for the data being loaded.

Workbook Queries – right click – edit – Advanced Editor

How to load data into Microsoft Excel from a database using Power Query
10

As we can see, the data was loaded on the page (Sheet) with the button Refresh All we can refresh the data. With his method Power Query we can have several Workbook Queries on several different pages (Sheets).

Of course we do not forget for security reasons to create users with minimum rights exclusively for this use.

Share it

Leave a reply