Excel connect to postgresql

Microsoft Excel is a spreadsheet program included in the Microsoft Office Suite. It’s compatible with Windows, Mac OS X, Android, and iOS. It simplifies the creation of text and numeric grids, formulas calculations, graphing tools, pivot tables, and the VBA Macro programming language (Visual Basic for Applications). Simple and advanced arithmetic operations and functions can be used to numerically manipulate grids of numbers organized in rows and columns.

PostgreSQL, sometimes known as Postgres, is a free and open-source Relational Database Management System (RDBMS) that emphasizes extensibility and SQL conformance. Structured objects are used instead of documents to store data in PostgreSQL. It employs conventional SQL syntax and formatting.

There are a variety of methods for importing Excel data into a PostgreSQL database; some are simple, while others are more complicated, depending on the sort of data you receive and the format it is in. In this article, you will learn everything about Excel to PostgreSQL along with the process which you might want to carry out while using it to make the process run smoothly.

What is PostgreSQL?

Excel to PostgreSQL: PostgreSQL logo

Image Source

PostgreSQL, or Postgres, is a free, open-source Relational Database Management System (RDBMS) that focuses on extensibility and SQL compliance. It was first released on July 8, 1996, and was developed at the University of California, Berkeley. It was the Ignes database’s successor. Instead of storing data in the form of documents, PostgreSQL uses Structured objects. It uses the standard SQL syntax and style.

It’s written in C and has a monolithic architecture, which means all of the parts are connected and work in a logical order. It provides community assistance and further assistance to some of its paid customers. Because of its novel backup systems, it is frequently employed in the Healthcare, Finance, and Industrial industries.

Key Features of PostgreSQL

PostgreSQL has some distinguishing characteristics that make it a viable alternative to other standard RDBMSs. The following are some of these characteristics:

  • PostgreSQL can handle a wide range of data, documents, and customization kinds.
  • It features a Monolithic Architecture, which means that all of the components function together automatically.
  • It’s perfect for transactional workflows like those found in bank systems, risk assessments, BI (Business Intelligence), and powering a variety of business applications.
  • Storage is reliable because of various fail-safes and redundancy.
  • Since it is open-source, anyone can utilize all of its features for free.
  • Since its processing capacity depends on the system it runs on, it has limited scalability.
  • It has a strong Access Control System with features such as row and column level security and multi-factor authentication with certificates.
  • It is ACID (Atomicity, Consistency, Isolation, and Durability) compliant and runs on major operating systems.

To learn more about PostgreSQL, you can check the official website here.

What is Microsoft Excel?

Excel to PostgreSQL: MS Excel logo

Image Source

Microsoft Excel is a Spreadsheet Application that is part of the Microsoft Office Suite. It runs on Windows, Mac OS X, Android, and iOS devices. It makes text and numeric grids, calculation of formulas, graphing tools, pivot tables, and the VBA Macro programming language easier to create (Visual Basic for Applications). To numerically manipulate grids of numbers organized in rows and columns, simple and sophisticated arithmetic operations and functions can be utilized.

Microsoft Excel is a spreadsheet program that may be used to create tables and record data. The information can range from a daily planner to financial information about a company. It also facilitates data analysis and the production of visualizations based on spreadsheet data.

Key Features of Microsoft Excel

  • Paste Special: When copying data from one cell to another, the user can also copy formatting, value, formula, comments, and other items, as well as their combinations, depending on the user’s needs.
  • Conditional Formatting: This feature draws attention to trends in your data as they appear in your spreadsheet.
  • Excel Pivot Tables: These can be used to sort, count, total, or average data from a single large spreadsheet and display it in whatever way the user chooses in a new table.
  • Add Multiple Rows: Users can add multiple rows and columns to their spreadsheets at any moment in Microsoft Excel.
  • Print Optimisation: Print Preview, Fit to One Page, Altering Margins, Print Selection, Printing Headers, Portrait vs. Landscape, and Spreadsheet Design are all options for printing Excel sheets to your satisfaction.
  • Vertical/Horizontal Formula Extention: Excel’s biggest feature is its ability to scale vertically and horizontally. Excel will conduct the necessary calculations any number of times once the formula is correct.
  • Index-Match: One of the most powerful Excel function combinations is Index-Match. It can be used to look up a value in a large Data Table and return its equivalent in the table.
  • Filters: Microsoft Excel provides capabilities that let you analyze data based on your own requirements. Filters are the terms for these functionalities.
  • Flash Fill: While copying data, Excel offers suggestions for making specific changes. Consider the following scenario: you have two columns of names and you need to produce email addresses for each of them. While you’re selecting an email address for one row, Excel will propose email addresses for all of the other rows based on their names.

For further information on Microsoft Excel, check the official website here.

Hevo Data, a No-code Data Pipeline helps to load data from any data source such as Google Sheets, FTP, Google Search Console, SaaS applications, Cloud Storage, SDKs, and Streaming Services to a destination of your choice like PostgreSQL and simplifies the ETL process like Excel to PostgreSQL. It supports 100+ data sources (including 40+ free data sources) and is a 3-step process by just selecting the data source, providing valid credentials, and choosing the destination. Hevo not only loads the data onto the desired Data Warehouse/destination but also enriches the data and transforms it into an analysis-ready form without having to write a single line of code.

Get started with hevo for free

Its completely automated pipeline offers data to be delivered in real-time without any loss from source to destination. Its fault-tolerant and scalable architecture ensure that the data is handled in a secure, consistent manner with zero data loss and supports different forms of data. The solutions provided are consistent and work with different BI tools as well.

Check out why Hevo is the Best:

  • Secure: Hevo has a fault-tolerant architecture that ensures that the data is handled in a secure, consistent manner with zero data loss.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
  • Minimal Learning: Hevo, with its simple and interactive UI, is extremely simple for new customers to work on and perform operations.
  • Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with very little latency.
  • Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
  • Live Monitoring: Hevo allows you to monitor the data flow and check where your data is at a particular point in time.

Sign up here for a 14-day free trial!

There are many methods to transfer data from Excel to PostgreSQL. You will gain an understanding of two of them.

Method 1: Integrating Excel to PostgreSQL using ODBC Drivers 

  • Step 1: Install ODBC Drivers for PostgreSQL
  • Step 2: Configure Postgres ODBC Driver in Excel
  • Step 3: Authorise Connection with PostgreSQL
  • Step 4: Load Data in Microsoft Excel

Get & Transform (Power Query) can be used to connect to PostgreSQL from Excel using ODBC. This approach presupposes you’ve installed a PostgreSQL ODBC Driver.

Step 1: Install ODBC Drivers for PostgreSQL

The first step in Excel to PostgreSQL data transfer is to install ODBC Driver. The PostgreSQL ODBC 64-bit driver is available for download. On the machine where the Secure Agent is installed, install the PostgreSQL ODBC driver.

Step 2: Configure Postgres ODBC Driver in Excel

Expand the Get Data drop-down box after clicking Data in Excel. Select From Other Sources > From ODBC from the drop-down menu.

Excel to PostgreSQL: Method 1 Step 2

Image Source

Step 3: Authorise Connection with PostgreSQL

Choose your data source name in the From ODBC dialogue (DSN). You can expand the Advanced Options dialogue box and input the connection string for your Data Source if you haven’t yet established your ODBC Driver (without credentials, which are defined in the credentials dialogue box in the next step). You can also enter a SQL query that will be performed immediately after connecting to the data source. Click the OK button.

Excel to PostgreSQL: Method 1 Step 3a

Image Source

Select Database and input your credentials in the dialog box, then click Connect if you’re using a database Username or Password. Select Default or Custom and press Connect if your database is not password-protected or if you’ve previously entered your credentials in the ODBC Data Source settings.

Excel to PostgreSQL: Method 1 Step 3b

Image Source

Step 4: Load Data in Microsoft Excel

Select the table from which you wish to retrieve data in the pop-up box and click on Load.

Excel to PostgreSQL: Method 1 Step 4a

Image Source

The table’s data will be displayed in an Excel spreadsheet, where you can interact with it further.

Excel to PostgreSQL: Method 1 Step 4b

Image Source

You have successfully completed Excel to PostgreSQL data transfer via ODBC Driver.

Method 2: Integrating Excel to PostgreSQL via CSV Files 

  • Step 1: Excel File Conversion
  • Step 2: CSV File Connection
  • Step 3: Data Import

Step 1: Excel File Conversion

The first step in the CSV method in Excel to PostgreSQL data transfer is to Excel FIle Conversion. Open your file in Microsoft Excel if the file extension is xls or xlsx. This will need to be converted to a CSV file, which is a simple process. Simply Save As and modify the “Save as type:” to “CSV (*.csv)” before clicking Save. There is no need to change the file name to .csv because it will change automatically.

Excel to PostgreSQL: Method 2 Step 2

Image Source

Step 2: CSV File Connection

Click Create and then Connection after right-clicking your Database Connection (or anyplace if your connections are empty). On the left, make sure the All tab is chosen, then scroll down to CSV. Now click Next.

Excel to PostgreSQL: Method 2 Step 2a

Image Source

Select the folder where you saved your CSV file from Microsoft Excel by clicking Browse. You’re choosing a folder rather than a file. All CSV files in that folder will be loaded by the connection. Finish by clicking the Finish button.

Excel to PostgreSQL: Method 2 Step 2b

Image Source

You should now notice a new connection, which is configured similarly to a standard connection. Each of the CSV files in your folder will be organized into a table with columns.

Excel to PostgreSQL: Method 2 Step 2c

Image Source

Step 3: Data Import

Data Import is the last step in the process of Excel to PostgreSQL data transfer. After you’ve established the connection, you may query the data using SQL syntax, just like any other table. This data can now be imported into your PostgreSQL Table. Select Export Data from the context menu of the table you want to import into PostgreSQL.

Excel to PostgreSQL: Method 2 Step 3a

Image Source

Click Next after selecting Database. Change the target container to the schema in PostgreSQL where your table resides. Click on the OK button.

Excel to PostgreSQL: Method 2 Step 3b

Image Source

Choose the target (table) for the data to be imported. Set the target column for each data column by clicking Columns. This will map automatically if you have headers in your data that match the table columns. Click the OK button. Now, Next should be selected.

Excel to PostgreSQL: Method 2 Step 3c

Image Source

Set the connection and Data Load options. Remove the option for truncating the target table if you only want to add data to the table rather than rewriting it. Now, Next should be selected.

Excel to PostgreSQL: Method 2 Step 3d

Image Source

After you’ve double-checked that the source and target are correct, click Start to begin the import.

The data from your PostgreSQL table is now available for selection.

Excel to PostgreSQL: Method 2 Step 3e

Image Source

You have successfully completed Excel to PostgreSQL data transfer via CSV files.

Conclusion

This article teaches you about Excel to PostgreSQL. It provides in-depth knowledge about the concepts behind every step to help you understand and implement them efficiently. If you want to transfer data into your desired Database/destination, then Hevo Data is the right choice! 

Visit our Website to Explore Hevo

Hevo Data provides users with a simpler platform for integrating data from 150+ sources such as Google Sheets, FTP, etc. for Analysis. It is a No-code Data Pipeline that can help you combine data from multiple sources. You can use it to transfer data from multiple data sources into your Data Warehouses, Databases such as PostgreSQL, or a destination of your choice. It helps you carry out ETL processes like Excel to PostgreSQL. It provides you with a consistent and reliable solution to managing data in real-time, ensuring that you always have Analysis-ready data in your desired destination.

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite firsthand. You can also have a look at our unbeatable pricing that will help you choose the right plan for your business needs!

Share your experience of learning about Excel to PostgreSQL! Let us know in the comments section below!

You can import data into Excel from a wide variety of data sources and the sections that follow show you how. For more information on what to do with your data once it’s imported, see How data journeys through Excel.

You can create a query from an Excel table, named range, or dynamic array in the current workbook. If the selected data is a simple range, it’s converted to a table. Importing dynamic arrays requires a Microsoft 365 subscription. For more information on dynamic arrays, see Dynamic array formulas and spilled array behavior.

  1. Select any cell within your data range.

  2. Select Data > From Table/Range.

    This command is also available from Data > From Other SourcesFrom Table/Range.

  3. If prompted, in the Create Table dialog box, you can select the Range Selection button to select a specific range to use as a data source.

    From Table dialog

  4. If the table or range of data has column headers, select My table has headers. The header cells are used to define the column names for the query.

  5. Select OK.

For more information, see Import from an Excel Table.

  1. Select Data > Get Data > From File > From Excel Workbook

  2. In the Excel Browse dialog box, browse for or type a path to the file that you want to query.

  3. Select Open.

If your source workbook has named ranges, the name of the range will be available as a data set.

For more information about advanced connector options, see Excel Workbook (docs.com).

The following procedure shows the basic steps. For more detailed coverage, see Import or export text (.txt or .csv) files.

  1. Select Data Get Data > From File > From Text/CSV

  2. In the Comma-Separated Values Browse dialog box, browse for or type a path to the file that you want to query.

  3. Select Open.

Note: If you are importing data from a CSV file, Power Query will automatically detect column delimiters including column names and types. For example, if you imported the example CSV file below, Power Query automatically uses the first row as the column names and changes each column data type.

Example CSV file

Image of a CSV file

Power Query automatically changes each column data type:

  • Order ID changes to number

  • Order Date changes to date

  • Category remains text (the default column type)

  • Product Name remains text (the default column type)

  • Sales changes to number

For more information about advanced connector options, see Text/CSV (docs.com).

The following procedure shows the basic steps of importing data. For more detailed coverage, see Import XML data.

  1. Select Data > Get Data > From File > From XML

  2. In the From XML Browse dialog box, browse for or type a file URL to import or link to a file.

  3. Select Open.

After the connection succeeds, use the Navigator pane to browse and preview the collections of items in the XML file in a tabular form.

For more information about advanced connector options, see XML (docs.com).

  1. Select Data > Get Data > From File > From JSON. The Import Data dialog box appears.

  2. Locate the JSON file, and then select Open.

For more information about advanced connector options, see JSON (docs.com).

Important   When you try to import a PDF file, you may get the following PDF message: “This connector requires one or more additional components to be installed before it can be used.” The PDF connector requires .NET Framework 4.5 or higher to be installed on your computer. You can download the latest .NET Framework from here. 

  1. Select Data > Get Data > From File > From PDF.

  2. Select your PDF file, and then click Open. The Navigator dialog box opens your PDF and displays available tables.

    The Navigator dialog box for importing PDF data

  3. Select the tables you want to import, then do one of the following:

    • To view the data directly in Excel, Select Load > Load or to see the Import dialog box, select Load > Load To.

    • To work with the data in Power Query first, select Transform Data.

For more information about advanced connector options, see PDF (docs.com).

You can import data from several files having a similar schema and format from a folder. Then, you can append the data into one table.

  1. Select Data > Get Data > From File > From Folder.

  2. In the Browse dialog box, locate the folder, and then select Open.

  3. For detailed steps, see Import data from a folder with multiple files.

For more information about advanced connector options, see Folder (docs.com).

You can import data from several files having a similar schema and format from a SharePoint library. Then, you can append the data into one table.

  1. Select Data > Get Data > From File > From SharePoint Folder.

  2. In the SharePoint Folder dialog box, enter the root URL for the SharePoint site not including any reference to a library, and then navigate to the library.

  3. For detailed steps, see Import data from a folder with multiple files.

For more information about advanced connector options, see SharePoint folder (docs.com).

  1. Select Data > Get Data > From Database > From SQL Server Database

  2. In the Microsoft SQL Database dialog box, specify the SQL Server to connect to in the Server Name box. Optionally, you can specify a Database Name as well.

  3. If you want to import data using a native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

    Power Query SQL Server Database connection dialog

  4. Select OK.

  5. Select the authentication mode to connect to the SQL Server database.

    Power Query SQL Server connection login credentials


    • Windows 
         This is the default selection. Select this if you want to connect using Windows authentication.

    • Database Select this if you want to connect using SQL Server authentication. After you select this, specify a user name and password to connect to your SQL Server instance.

  6. By default, the Encrypt connection check box is selected to signify that Power Query connects to your database using an encrypted connection. If you do not want to connect using an encrypted connection, clear this check box, and then click Connect.

    If a connection to your SQL Server is not established using an encrypted connection, Power Query prompts you to connect using an unencrypted connection. Click OK in the message to connect using an unencrypted connection.

For more information about advanced connector options, see SQL Server database (docs.com).

  1. Select Data > Get Data > From Database > From Microsoft Access Database

  2. In the Import Data dialog box, browse for and locate the Access database file (.accdb). 

  3. Select the file, and then select Open. The Navigator dialog box appears.

  4. Select the table or query in the left pane to preview the data in the right pane.

  5. If you have many tables and queries, use the Search box to locate an object or use the Display Options along with the Refresh button to filter the list.

  6. Select Load or Transform.

For more information about advanced connector options, see Access database (docs.com).

Note    When you use a workbook connected to a SQL Server Analysis Services database, you may need additional information to answer specific product questions, such as reference information about multidimensional expressions (MDX), or configuration procedures for an online analytical processing (OLAP) server.

  1. Select Data > Get External Data > From Database > From Analysis Services. The first page of the Data Connection Wizard appears. Its title is Connect to Database Server.

    Data Connection Wizard screen 1

  2. In the Server name box, enter the name of the OLAP database server.

    Tip: If you know the name of the offline cube file that you want to connect to, you can type the complete file path, file name, and extension.

  3. Under Log on credentials, do one of the following, then click Next:

    • To use your current Windows user name and password, click Use Windows Authentication.

    • To enter a database user name and password, click Use the following User Name and Password, and then type your user name and password in the corresponding User Name and Password boxes.

      Security Note

      • Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don’t mix these elements. For example, Y6dh!et5 is a strong password and House27 is a weak password. Passwords should contain 8 or more characters. A pass phrase that uses 14 or more characters is better.

      • It is critical that you remember your password. If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

  4. Select Next to go to the second wizard screen. Its title is Select Database and Table.

    Data Connection Wizard screen 2

    To connect to a specific cube file in the database, make sure that Connect to a specific cube or table is selected, and then select a cube from the list.

  5. In the Select the database that contains the data you want box, select a database, and then click Next.

  6. Click Next to go to the third wizard screen. Its titled Save Data Connection File and Finish.

    Data Connection Wizard screen 3

  7. In the File Name box, revise the default file name as needed (optional).

  8. Click Browse to change the default file location of My Data Sources, or check for existing file names.

  9. In the Description, Friendly Name, and Search Keywords boxes, type a description of the file, a friendly name, and common search words (all are optional).

  10. To ensure that the connection file is used when the PivotTable is refreshed, click Always attempt to use this file to refresh this data.

    Selecting this check box ensures that updates to the connection file will always be used by all workbooks that use that connection file.

  11. You can specify how a PivotTable is accessed if the workbook is saved to Excel Services and is opened by using Excel Services. 

    Note: The authentication setting is only used by Excel Services, and not by Microsoft Office Excel. If you want to ensure that the same data is accessed whether you open the workbook in Excel or Excel Services, make sure that the authentication setting in Excel is the same.

    Select Authentication Settings, and select one of the following options to log on to the data source: 

    • Windows Authentication       Select this option to use the Windows username and password of the current user. This is the most secure method, but it can affect performance when there are many users.

    • SSO       Select this option to use Single Sign On, and then enter the appropriate identification string in the SSO ID text box. A site administrator can configure a SharePoint site to use a Single Sign On database where a username and password can be stored. This method can be the most efficient when there are many users.

    • None       Select this option to save the username and password in the connection file.

      Important: Avoid saving logon information when connecting to data sources. This information may be stored as plain text, and a malicious user could access the information to compromise the security of the data source.

  12. Select OK.

  13. Select Finish to close the Data Connection Wizard. The Import Data dialog box appears.

    Import data

  14. Decide how you want to import the data, and then select OK. For more information about using this dialog box, select the question mark (?).

You can create a dynamic connection between an Excel workbook and a SQL Server Analysis Services Online Analytical Processing (OLAP) database server, then refresh that connection whenever the data changes. You can connect to a specific offline cube file if it has been created on the database server. You can also import data into Excel as either a Table or a PivotTable report.

  1. Select Data > Get Data > From Database > From SQL Server Analysis Services Database (Import)

  2. Enter the Server name, and then select OK.

    Note: You have the option of entering a specific database name, and you can also add an MDX (docs.com) or DAX query.

  3. In the Navigator pane select the database, and then select the cube or tables you want to connect.

  4. Click Load to load the selected table into a worksheet, or click Edit to perform additional data filters and transformations in the Power Query Editor before loading it.

  1. Select Data > Get Data > From Database > From Oracle Database.

  2. In the Oracle Database dialog box, in Server Name specify the Oracle Server to connect to. If a SID is required, this can be specified in the form of “ServerName/SID”.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import data from database using Native Database Query.

  4. Select OK.

  5. If the Oracle server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Connect.

For more information about advanced connector options, see Oracle Database (docs.com).

Warning: 

  • Before you can connect to an IBM DB2 database, you need the IBM DB2 Data Server Driver installed on your computer (minimum requirement is the IBM Data Server Driver Package (DS Driver)). Select the driver that matches your Power Query installation (32-bit or 64-bit).

  • There are known issues reported by IBM installing the IBM DB2 Data Server Driver on Windows 8. If you are using Windows 8 and want to connect to IBM DB2 using Power Query, you need to follow additional installation steps. Find more information about the IBM DB2 Data Server Driver on Windows 8.

  1. Select Data > Get Data > From Database > From IBM DB2 Database

  2. In the IBM DB2 Database dialog box, in Server Name specify the IBM DB2 Database Server to connect to.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import data from a database using Native Database Query.

  4. Select OK.

  5. If the IBM DB2 server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Connect.

For more information about advanced connector options, see IBM DB2 database (docs.com).

Note: If receive the message “This connector requires one or more additional components to be installed before it can be used.”, you need to download the appropriate ODBC Driver for MySQL to your Windows device from here. For more information, see MySQL Connectors.

  1. Select Data > Get Data > From Database > From MySQL Database

  2. In the MySQL Database dialog box, in Server Name specify the MySQL Database Server to connect to.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import data from a database using Native Database Query.

  4. Select OK.

  5. If the MySQL server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Connect.

For more information about advanced connector options, see MySQL database (docs.com).

Note: Before you can connect to a PostgreSQL database in Power Query, you need the Ngpsql data provider for PostgreSQL installed on your computer. Select the driver that matches your Office version (32-bit or 64-bit). For more information, see Which version of Office am I using? . Also make sure you have the provider registered in the machine configuration that matches the most recent .NET version on your device.

  1. Select Data > Get Data > From Database > From PostgreSQL Database

  2. In the PostgreSQL Database dialog box, specify the PostgreSQL Database Server you want to connect to in the Server Name section.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import data from a database using Native Database Query.

  4. Select OK.

  5. If the PostgreSQL server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Select Connect.

For more information about advanced connector options, see PostgreSQL (docs.com).

Note: Before you can connect to an SAP SQL Anywhere database, you need the  SAP SQL Anywhere driver installed on your computer. Select the driver that matches your Excel installation (32-bit or 64-bit).

  1. Select Data > Get Data > From Database > From Sybase Database

  2. In the Sybase Database dialog box, specify the Sybase Server to connect to in the Server Name box. Optionally, you can specify a Database Name as well.

  3. If you want to import data using a native database query, specify your query in the SQL Statement box. For more information, see Import data from a database using Native Database Query.

  4. Select OK.

  5. By default, the Encrypt connection check box is selected so that Power Query connects to your database using a simple encrypted connection.

  6. Select Connect.

For more information, see Sybase database (docs.com).

  1. Select Data > Get Data > From Database > From Teradata Database.

  2. In the Teradata Database dialog box, in Server Name specify the Teradata Server to connect to.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import data from a database using Native Database Query.

  4. Select OK.

  5. If the Teradata server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Save.

For more information, see Terabase database (docs.com).

Notes: 

  • This feature is only available in Excel for Windows if you have Office 2019 or later, or a Microsoft 365 subscription. If you are a Microsoft 365 subscriber, make sure you have the latest version of Office.

  • Before you can connect to an SAP HANA database using Power Query, you need the SAP HANA ODBC Driver on your computer. Select the driver that matches your Power Query installation (32-bit or 64-bit).

  • You will need an SAP account to login to the website and download the drivers. If you are unsure, contact the SAP administrator in your organization.

To connect to an SAP HANA database:

  1. Click Data > New Query > From Database > From SAP HANA Database.

  2. In the SAP HANA Database dialog box, specify the server you want to connect to. The server name should follow the format ServerName:Port.

    SAP HANA Database dialog box

  3. Optionally, if you want to import data using native database query, Select Advanced options and in the SQL Statement box enter the query.

  4. Select OK.

  5. If the SAP HANA server requires database user credentials, then in the Access an SAP HANA database dialog box, do the following:

    1. Click the Database tab, and enter your username and password.

    2. Click Connect

For more information about advanced connector options, see SAP HANA database (docs.com).

Azure SQL Database is a high-performing, fully managed, scalable relational database built for the cloud and used for mission-critical applications. For more information, see What is Azure SQL? (docs.com).

  1. Select Data > Get Data > From Azure > From Azure SQL Database.

  2. In the Microsoft SQL Database dialog box, specify the SQL Server to connect to in the Server Name box. Optionally, you can specify a Database Name as well.

  3. If you want to import data using a native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

    Power Query SQL Server Database connection dialog

  4. Select OK.

  5. Select the authentication mode to connect to the SQL Server database.

    Power Query SQL Server connection login credentials


    • Windows 
         This is the default selection. Select this if you want to connect using Windows authentication.

    • Database Select this if you want to connect using SQL Server authentication. After you select this, specify a user name and password to connect to your SQL Server instance.

  6. By default, the Encrypt connection check box is selected to signify that Power Query connects to your database using an encrypted connection. If you do not want to connect using an encrypted connection, clear this check box, and then click Connect.

    If a connection to your SQL Server is not established using an encrypted connection, Power Query prompts you to connect using an unencrypted connection. Click OK in the message to connect using an unencrypted connection.

For more information about advanced connector options, see Azure SQL database (docs.com).

Azure Synapse Analytics combines big data tools and relational queries by using Apache Spark to connect to Azure data services and the Power Platform. You can load millions of rows in no time. Then, you can work with tabular data by using familiar SQL syntax for queries. For more information, see What is Azure Synapse Analytics (docs.com).

  1. Select Data > Get Data > From Azure > From Azure Synapse Analytics.

  2. In the Microsoft SQL Database dialog box, specify the SQL Server to connect to in the Server Name box. Optionally, you can specify a Database Name as well.

  3. If you want to import data using a native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

    Power Query SQL Server Database connection dialog

  4. Select OK.

  5. Select the authentication mode to connect to the SQL Server database.

    Power Query SQL Server connection login credentials


    • Windows 
         This is the default selection. Select this if you want to connect using Windows authentication.

    • Database Select this if you want to connect using SQL Server authentication. After you select this, specify a user name and password to connect to your SQL Server instance.

  6. By default, the Encrypt connection check box is selected to signify that Power Query connects to your database using an encrypted connection. If you do not want to connect using an encrypted connection, clear this check box, and then click Connect.

    If a connection to your SQL Server is not established using an encrypted connection, Power Query prompts you to connect using an unencrypted connection. Click OK in the message to connect using an unencrypted connection.

For more information about advanced connector options, see Azure Synapse Analytics (docs.com).

Azure HDInsight is used for big data analysis when you need to process large amounts of data. It supports data warehousing and machine learning; you can think of it as a data flow engine. For more information, see What is Azure HDInsight? (docs.com).

  1. Select Data > Get Data > From Azure > From Azure HDInsight (HDFS)

  2. Enter the Account name or URL of the Microsoft Azure Blob Storage account associated with your HDInsight cluster, and then select OK.

  3. In the Access Microsoft Azure HDInsight dialog box, enter your Account Key, and click Connect.

  4. Select your cluster in the Navigator dialog, and then find and select a content file.

  5. Select Load to load the selected table, or Edit to perform additional data filters and transformations before loading it.

Microsoft Azure Blob Storage is a service for storing large amounts of unstructured data, like images, videos, audio, and documents, which can be accessed from anywhere in the world via HTTP or HTTPS. For more information about Azure Blob Storage service, see How to Use Blob Storage.

  1. Select Data > Get Data > From Azure > From Azure Blob Storage

  2. In the Microsoft Azure Blob Storage dialog box, enter your Microsoft Azure  storage account name or URL, and then select OK.

  3. If you are connecting to the Blob storage service for the first time, you will be prompted to enter and save the storage access key. In the Access Microsoft Azure Blob Storage dialog box, enter your storage access key in the Account Key box, and click Save.

    Note: If you need to retrieve your storage access key, browse to the Microsoft Azure Portal, select your storage account, and then select the Manage Access Key icon on the bottom of the page. Select the copy icon to the right of the primary key, and then paste the value in the Account Key box.

  4. The Query Editor lists all the available containers in your Microsoft Azure Blob Storage. In the Navigator, select a container from where you want to import data, and then select Apply & Close.

For more information, see Azure Blob Storage (docs.com).

The Azure Storage provides storage services for a variety of data objects. The Table storage component targets NoSQL data stored as key/attribute pairs. For more information, see Introduction to Table storage (docs.com).

  1. Select Data > Get Data > From Azure > From Azure Synapse Analytics.

  2. Enter the Account name or URL of the Microsoft Azure Table Storage account, and then select OK.

  1. Select Data > Get Data > From Azure > From Azure Data Lake Storage.

  2. Enter the Account name or URL of the Microsoft Azure Data Lake Storage account, and then select OK.

    For example: swebhdfs://contoso.azuredatalake.net/

  3. Optionally, enter a value in the Page Size in Bytes box.

For more information, see Azure Data Lake Storage (docs.com).

Azure Data Lake Storage Gen 2 combines different data warehouses into a single, stored environment. You can use a new generation of query tools to explore and analyze data, working with petabytes of data. For more information, see Azure Data Lake Storage (docs.com).

  1. In the Azure Data Lake Storage Gen2 dialog box, provide the account URL. URLs for Data Lake Storage Gen2 have the following pattern:

    https://<accountname>.dfs.core.windows.net/<container>/<subfolder>
    For example, https://contosoadlscdm.dfs.core.windows.net/

  2. Select whether you want to use the File System View or the Common Data Model (CDM) Folder View.

  3. Select OK.

  4. You may need to choose an authentication method.

    For example, if you select the Organizational account method, select Sign in to sign into your storage account. You’ll be redirected to your organization’s sign-in page. Follow the prompts to sign into the account. After you’ve successfully signed in, select Connect.

  5. In the Navigator dialog box verify the information, and then select either Transform Data to transform the data in Power Query or Load to load the data.

For more information, see Azure Data Lake Storage (docs.com).

Azure Data Explorer is a fast and highly scalable data exploration service for log and telemetry data. It can handle large volumes of diverse data from any data source, such as websites, applications, IoT devices, and more. For more information, see What is Azure Data Explorer (docs.com).

  1. Select Data > Get Data > From Azure > From Azure Data Explorer.

  2. In the Azure Data Explorer (Kusto) dialog box, enter appropriate values.

    Each prompt provides helpful examples to walk you through the process.

  3. Select OK.

You can import Datasets from your organization with appropriate permission by selecting them from the Power BI Datasets pane, and then creating a PivotTable in a new worksheet.

  1. Select Data > Get Data > From Power BI (<Tenant name>). The Power BI Datasets pane appears. <Tenant name> varies depending on your organization, for example, Power BI (Contoso).

  2. If many Datasets are available, use the Search box. Select the arrow next to the box to display keyword filters for versions and environments to target your search.

  3. Select a Dataset and create a PivotTable in a new worksheet. For more information, see Overview of PivotTables and PivotCharts.

For more information on Power BI, see Create a PivotTable from Power BI datasets and Data Management Experience in Power BI for Office 365 Help (docs.com).

A dataflow is a data preparation technology that enables ingesting, transforming, and loading data into Microsoft Dataverse environments, Power BI workspaces, or Azure Data Lake. You can trigger dataflows to run either on demand or automatically on a schedule so that data is always kept up to date.

  1. Select Data > Get Data > From Power Platform > From Dataflows.

  2. If prompted, enter the required credentials, or sign in as a different user. The Navigator pane appears.

  3. Select the dataflow in the left pane to preview it in the right pane.

  4. Do one of the following:

    • To add the data to a worksheet, select Load.

    • To add the data to the Power Query Editor, select Transform Data.

For more information, see An overview of dataflows across Microsoft Power Platform.

Use Dataverse to securely store and manage data in the cloud. You can create or import custom tables specific to your organization, populate them with data by using Power Query, and then use Power Apps or Microsoft Access to build rich business applications.

  1. Select Data > Get Data > From Power Platform > From Dataverse.

  2. If prompted, enter the required credentials, or sign in as a different user. The Navigator pane appears.

  3. Select the data in the left pane to preview it in the right pane.

  4. Do one of the following:

    • To add the data to a worksheet, select Load.

    • To add the data to the Power Query Editor, select Transform Data.

For more information, see What is Microsoft Dataverse.

  1. Select Data > Get Data > From Online Services > From SharePoint Online List.

  2. In the SharePoint Folder dialog box, enter the root URL for the SharePoint site not including any reference to a library, and then navigate to the library.

  3. Select the 2.0 Beta SharePoint implementation, which enables Advanced options, so you can select a View mode:

    All    Retrieves all columns from a SharePoint List.
    Default    Retrieves the columns set in the Default View of a SharePoint List.

  4. As an alternative to 2.0 Beta, you can select 1.0, which corresponds to the earlier version of SharePoint.

For more information about advanced connector options, see SharePoint Online list (docs.com).

  1. Select Data > Get Data > From Online Services from SharePoint Online List.

  2. In the Microsoft Exchange dialog box enter your email address in the form of <alias>@<organization>.com

  3. If you have many objects, use the Search box to locate an object or use he Display Options along with the Refresh button to filter the list.

  4. Select or clear the Skip files with errors checkbox at the bottom of the dialog box.

  5. Select the table you want: Calendar, Mail, Meeting Requests, People, and Tasks.

  6. Do one of the following:

  • To create a query, and then load to a worksheet, select Load > Load.

  • To create a query, and then display the Import Data dialog box, select Load > Load To.

  • To create a query, and then launch the Power Query Editor, select Transform Data.

  1. Select the Environment you want to connect to.

  2. In the menu, select the Settings icon > Advanced customizations > Developer resources.

  3. Copy the Instance Web API value. 

    Notes: 

    • The url format will be something like https://<tenant>.crm.dynamics.com/api/data/v9.0.

    • The exact format of the URL you will use to connect depends on your region and the version of CDS for Apps you’re using. For more information see: Web API URL and versions (docs.com).

  4. Select Data > Get Data > From Online Services > From Dynamics 365 (online).

  5. In the dialog box, with the Basic option selected, enter the Web API URL for your CDS for Apps connection, and click OK.

    • If you select the Advanced option, you can append certain additional parameters to the query to control what data is returned. For more information see: Query Data using the Web API (docs.com).

  6. Select Organization account.

    • If you aren’t signed in using the Microsoft Work or School account you use to access Dataverse for Apps, select Sign in and enter the account username and password.

  7. Select Connect.

  8. Within the Navigator dialog, select the data you want to retrieve.

  9. Verify the data is correct, and then select Load or Edit to open the Power Query Editor.

  1. Select Data > Get Data > From Online Services > From Salesforce Objects. The Salesforce Objects dialog box appears.

  2. Select either Production or Custom. If you select Custom, enter the URL of a custom instance.

  3. Select or clear Include relationships column.

  4. Select OK.

For more information about advanced connector options, see Salesforce Objects (docs.com).

Because Salesforce Reports has API limits retrieving only the first 2,000 rows for each report, consider using the Salesforce Objects connector to work around this limitation if needed.

  1. Select Data > Get Data > From Online Services > From Salesforce Reports. The Salesforce Reports dialog box appears.

  2. Select either Production or Custom. If you select Custom, enter the URL of a custom instance.

  3. Select or clear Include relationships column.

  4. Select OK.

For more information about advanced connector options, see Salesforce Reports (docs.com).

Make sure you have the latest version of the Adobe Analytics connector. For more information, see Connect to Adobe Analytics in Power BI Desktop (docs.com).

  1. Select Data > Get Data > From Online Services > From Adobe Analytics.

  2. Select Continue. The Adobe Account dialog box appears.

  3. Sign in with you Adobe Analytics Organizational account, and then select Connect.

For more information about advanced connector options, see Adobe Analytics.

For more information, see From Table/Range.

Important: 

  • When you try to import a data from the web, you may get the following message:  “This connector requires one or more additional components to be installed before it can be used.” The Web connector requires WebView 2 Framework to be installed on your computer. 

  • You can download it from here. 

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Procedure

  1. Select Data > New Query > From Other Sources > From Web.

  2. In the From Web dialog box, enter a web page URL, then click OK.

    Power Query > From Web > Input URL dialog

    In this case, we’re using: http://en.wikipedia.org/wiki/UEFA_European_Football_Championship.

    If the web page requires user credentials:

    • Select Advanced, and then In the Access Web dialog box, enter your credentials.

    • Select Save.

  3. Select OK.

  4. In the  Navigator pane, do the following:

    Select Table View, such as Results.

    Power Query > From Web > Navigator Table View

    Select Web View to see the table as a web page.

    Power Query > From Web > Navigator > Web View

  5. Select Load to load the data into a worksheet.

For more information about advanced connector options, see Web (docs.com).

  1. Select Data > Get Data > From Other Sources > From SharePoint List.

  2. In the Microsoft SharePoint Lists dialog box, enter the URL for a SharePoint site.

    Note: When connecting to a SharePoint list, enter the site URL instead of the list URL. In the Access SharePoint dialog box, select the most general URL to authenticate against the site correctly. By default, the most general URL is selected.

  3. Select OK.

  4. In the Access SharePoint dialog box, select a credentials option:

    • Select Anonymous if the SharePoint Server does not require any credentials.

      Excel Power Query connect to a Sharepoint List Connect dialog

    • Select Windows if the SharePoint Server requires your Windows credentials.

    • Select Organizational account if the SharePoint Server requires organizational account credentials.

  5. Select Connect.

For more information about advanced connector options, see SharePoint list (docs.com).

  1. Select Data > Get Data > From Other Sources > From OData Feed

  2. In the OData Feed dialog box, enter the URL for an OData feed.

  3. Select OK.

  4. If the OData feed requires user credentials, in the Access an OData feed dialog box:

    1. Select Windows if the OData feed requires Windows Authentication.

    2. Select Basic if the OData feed requires your username and password.

    3. Select Marketplace key if the OData feed requires a Marketplace account key. You can select the Get your Marketplace Account Key to subscribe to Microsoft Azure Marketplace OData feeds. You can also Sign up for Microsoft Azure Marketplace from the Access an OData Feed dialog box.

    4. Click Organizational account if the OData feed requires federated access credentials. For Windows Live ID, log into your account.

    5. Select Save.

Note: Importing to an OData feed supports the JSON light data service format.

For more information about advanced connector options, see OData feed (docs.com).

Hadoop Distributed File System (HDFS) is designed to store terabytes and even petabytes of data. HDFS connects computer nodes within clusters over which data files are distributed and you can access these data files as one seamless file stream.

  1. Select Data > Get Data > From Other Sources > From Hadoop File (HDFS).

  2. Enter the name of the server in the Server box, and then select OK.

  1. Select Data > Get Data > From Other Sources > From Active Directory.

  2. Enter your domain in the Active Directory dialog box.

  3. In the Active Directory Domain dialog box for your domain, select Use my current credentials, or select Use alternate credentials and then enter your Username and Password.

  4. Select Connect.

  5. After the connection succeeds, use the Navigator pane to browse all the domains available within your Active Directory, and then drill down into Active Directory information including Users, Accounts, and Computers.

  1. Select Data > Get Data > From Other Sources > From Microsoft Exchange

  2. In the Access an Exchange Server dialog box, enter your Email Address and Password.

  3. Select Save.

  4. In the Microsoft Exchange Autodiscover Service dialog box, select Allow to allow the Exchange Service to trust your credentials.

  1. Select Data > Get Data > From Other Sources > From ODBC

  2. In the From ODBC dialog box, if displayed, select your Data Source Name (DSN).

  3. Enter your connection string, and then select OK.

  4. In the next dialog box, select from Default or Custom, Windows, or Database connection options, enter your credentials, and then select Connect.

  5. In the Navigator pane, select the tables or queries that you want to connect to, then select Load or Edit.

For more information about advanced connector options, see ODBC data source (docs.com).

  1. Select Data > Get Data > From Other Sources > From OLEDB

  2. In the From OLE DB dialog box, enter your connection string, and then select OK.

  3. In the OLEDB Provider dialog, select from the Default or Custom, Windows, or Database connection options, enter the appropriate credentials, and then select Connect.

  4. In the Navigator dialog box, select the database, and tables or queries you want to connect to, and then select Load or Edit.

Important: 
Retirement of Facebook data connector notice     Import and refresh data from Facebook in Excel will stop working in April, 2020. You will still be able to use the Facebook Power Query (Get & Transform)  connector until then, but starting in April, 2020, you will be unable to connect to Facebook and will receive an error message. We recommend revising or removing any existing Power Query (Get & Transform) queries that use the Facebook connector as soon as possible to avoid unexpected results.

Note: If this is the first time you’ve connected to Facebook, you will be asked to provide credentials. Sign in using your Facebook account, and allow access to the Power Query application. You can turn off future prompts by clicking the Don’t warn me again for this connector option.

  1. On the Data tab, click Get Data > From Online Services > From Facebook. If you don’t see the Get Data button, click New Query > From Other Sources > From Facebook.

  2. In the Facebook dialog box, connect to Facebook using “Me”, your Username, or Object ID.

    Note: Your Facebook username is different from your login email.

  3. Select a category to connect to from the Connection drop-down list. For example, select Friends to give you access to all information available in your Facebook Friends category.

  4. Click OK.

  5. If necessary, click Sign in from the Access Facebook dialog, then enter your Facebook email or phone number, and password. You can check the option to remain logged in. Once signed in, click Connect.

  6. After the connection succeeds, you will be able to preview a table containing information about the selected category. For instance, if you select the Friends category, Power Query renders a table containing your Facebook friends by name.

  7. Click Load or Edit.

You can create a blank query. You might want to enter data to try out some commands, or you can select the source data from Power Query:

  • To change a setting such as credentials or privacy, select Home > Data Source Settings. For more information, see Manage data source settings and permissions.

  • To import an external data source, select Home > New Source. This command is similar to the Get Data command on the Data tab of the Excel ribbon.

  • To import a recent source, select Home > Recent Sources. This command is similar to the Recent Sources command on the Data tab of the Excel ribbon.

When you append two or more queries, the data is added to a query based on the names of the column headers in both tables. If the queries don’t have matching columns, null values are added to the unmatched column. The queries are appended in the order in which they’re selected.

For more information, see Append queries (Power Query) and Append queries (docs.com).

If you are a developer, there are several approaches within Excel that you can take to import data:

  • You can use Visual Basic for Applications to gain access to an external data source. Depending on the data source, you can use either ActiveX Data Objects or Data Access Objects to retrieve the data. You can also define a connection string in your code that specifies the connection information. Using a connection string is useful, for example, when you want to avoid requiring system administrators or users to first create a connection file, or to simplify the installation of your application.

  • If you import data from an SQL Server database, consider using SQL Native Client, which is a standalone data access Application Programming Interface (API) that is used for both OLE DB and ODBC. It combines the SQL OLE DB Provider and the SQL ODBC Driver into one native, dynamic link library (DLL), while also providing new functionality that is separate and distinct from the Microsoft Data Access Components (MDAC). You can use SQL Native Client to create new applications or enhance existing applications that can take advantage of newer SQL Server features, such as Multiple Active Result Sets (MARS), User-Defined Types (UDT), and XML data type support.

  • The RTD function retrieves real-time data from a program that supports COM automation. The RTD COM automation add-in must be created and registered on a local computer.

  • The SQL.REQUEST function connects with an external data source and runs a query from a worksheet. The SQL.REQUEST function then returns the result as an array without the need for macro programming. If this function is not available, you must install the Microsoft Excel ODBC add-in program (XLODBC.XLA). You can install the add-in from Office.com.

For more information about creating Visual Basic for Applications, see Visual Basic Help.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select Excel workbook.

  3. Select Browse to locate the file you want to connect as the data source.

  4. In the File picker dialog box, select the file, review the file details, and then select Get Data and Next.

  5. On the left, select the data you want to import, and then on the right, confirm the selection in data preview.

  6. At the bottom right, select Load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select Text/CSV.

  3. Select Browse to locate the file you want to connect as the data source.

  4. In the File picker dialog box, select the file, review the file details, and then select Get Data and Next.

  5. Confirm the file origin and delimiter selection in data preview.

  6. At the bottom right, select Load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select XML.

  3. Select Browse to locate the file you want to connect as the data source.

  4. In the File picker dialog box, select the file, review the file details, and then select Get Data and Next.

  5. On the left, select the data you want to import, and then on the right, confirm the selection in data preview.

  6. At the bottom right, select Load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select JASON.

  3. Select Browse to locate the file you want to connect as the data source.

  4. In the File picker dialog box, select the file, review the file details, and then select Get Data and Next.

  5. At the bottom right, select Close & Load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select SQL Server database.

  3. Under Connection settings, enter the name of the server.

  4. Under Connection credentials, enter the username and password, decide whether to use an encrypted connection, and then select Next.

  5. On the left, select the data you want to import, and then on the right, confirm the selection in data preview.

  6. At the bottom right, select Load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select SharePoint Online list.

  3. In the Connect to data source dialog box, enter the root URL for the SharePoint site not including any reference to a library, and then sign in to your organizational account.

  4. Select the 2.0 SharePoint implementation, which enables Advanced options, so you can select a View mode:

    • All which retrieves all columns from a SharePoint List.

    • Default which retrieves the columns set in the Default View of a SharePoint List.

    Note    As an alternative to 2.0, you can select 1.0, which corresponds to the earlier version of SharePoint.

  5. Select Next.

  6. On the left, select the data you want to import, and then on the right, confirm the selection in data preview.

  7. At the bottom right, select Load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select OData.

  3. In the OData Feed dialog box, enter the URL for the OData feed.

  4. If the OData feed requires user credentials, in the Connection credentials dialog box under Authentication kind:

    • Select Basic if the OData feed requires your username and password.

    • Select Organizational account if the OData feed requires federated access credentials, and select Sign in.

  5. Select Next.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select Blank table.

  3. Enter the desired data to the cells of the table. You can also rename the table under Name at the bottom.

  4. Select Next.

  5. After editing the query, on the top-right select Close & load.

  1. Select Data > Get Data (Power Query).

  2. In the Choose data source dialog box, select Blank query.

  3. Enter the desired source and commands and then select Next.

  4. After editing the query, on the top-right select Close & load.

You can use the Power Query add-in to connect to external data sources and perform advanced data analyses. The following sections provide steps for connecting to your data sources — web pages, text files, databases, online services, and Excel files, tables, and ranges.

Important: Before you can use Power Query in Excel 2013, you must activate it: click File > Options > Add-Ins. In the Manage section at the bottom, choose the COM Add-ins option from the drop-down list, then click Go. Click the Power Query check box, then OK. The Power Query ribbon should appear automatically, but if it doesn’t, close and restart Excel.

Using the Query Editor

Note: The Query Editor appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

  1. In the Power Query ribbon tab, click From File > From CSV, or From Text.

  2. In the Comma-Separated Values Browse dialog box, browse for or type a path to the file that you want to query.

  3. Click Open.

Note: If you are importing data from a CSV file, Power Query will automatically detect column delimiters including column names and types. For example, if you imported the example CSV file below, Power Query automatically uses the first row as the column names and changes each column data type.

Example CSV file

Image of a CSV file

Power Query automatically changes each column data type:

  • Order ID changes to number

  • Order Date changes to date

  • Category remains text (the default column type)

  • Product Name remains text (the default column type)

  • Sales changes to number

In the Query Editor, Power Query automatically applies a FirstRowAsHeader step and ChangeType step. These automatic actions are equivalent to manually promoting a row and manually changing each column type.

After Power Query auto detects columns, you can also use the Query Editor to write formulas for Power Query. For example:

= Csv.Document(File.Contents("C:ExamplesProducts Categories and Orders.csv"),null,",",null,1252)

= Table.PromoteHeaders(Source)

= Table.TransformColumnTypes(FirstRowAsHeader,{{"OrderID", type number}, {"CustomerID", type text}, {"EmployeeID", type number}, {"OrderDate", type date}, {"RequiredDate", type date}, {"ShipName", type text}})

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window in Excel 2013 appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

  1. Select any cell within your data range.

  2. In the Power Query ribbon tab, click From Table.

    Connect to an Excel Data Table

  3. If prompted, in the From Table dialog box, you can click the Range Selection button to select a specific range to use as a data source.

    From Table dialog

  4. If the range of data has column headers, you can check My table has headers. The range header cells are used to set the column names for the query.

  5. In the Query Editor, click Close & Load.

Note: If your data range has been defined as a named range, or is in an Excel table, then Power Query will automatically sense the entire range and load it into the Query Editor for you. Plain data will automatically be converted to a table when it is loaded into the Query Editor.

You can use the Query Editor to write formulas for Power Query.

= Excel.CurrentWorkbook(){[Name="Table1"]}[Content]

Query Editor Formula Sample

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

  1. In the Power Query ribbon tab, click From File > From Excel.

  2. In the Excel Browse dialog box, browse for or type a path to the file that you want to query.

  3. Click Open.

    If your source workbook has named ranges, the name of the range will be available as a data set.

You can also use the Query Editor to write formulas for Power Query. For example:

= Excel.Workbook
 (File.Contents("C:ExampleProducts and Orders.xlsx"))

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window in Excel 2013 appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

Note: While trying to import data from a legacy Excel file or an Access database in certain setups, you may encounter an error that the Microsoft Access Database Engine (Microsoft.ACE.OLEDB.12.0 provider) is not registered on the local machine. The error occurs on systems with only Office 2013 installed. To resolve this error, download the following resources to ensure that you can proceed with the data sources you are trying to access.

  • Microsoft Access Database Engine 2010 Redistributable

  • Access Database Engine 2010 Service Pack 1

  1. Click the Power Query ribbon, then From Web.

  2. In the From Web dialog box, enter a web page URL, then OK.

    Power Query > From Web > Input URL dialog

    In this case, we’re using: http://en.wikipedia.org/wiki/UEFA_European_Football_Championship.

    If the web page requires user credentials:

    • In the Access Web dialog box, click a credentials option, and provide authentication values.

    • Click Save.

  3. Click OK.

  4. Power Query will analyze the web page, and load the Navigator pane in Table View.

    If you know which table you want to connect to, then click it from the list. For this example, we chose the Results table.

    Power Query > From Web > Navigator Table View

    Otherwise, you can switch to the Web View and pick the appropriate table manually. In this case, we’ve selected the Results table.

    Power Query > From Web > Navigator > Web View

  5. Click Load, and Power Query will load the web data you selected into Excel.

  1. In the Power Query ribbon tab, click From Database > From SQL Server Database.

    Power Query From Database options

  2. In the Microsoft SQL Database dialog box, specify the SQL Server to connect to in the Server Name box. Optionally, you can specify a Database Name as well.

  3. If you want to import data using a native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

    Power Query SQL Server Database connection dialog

  4. Select OK.

  5. Select the authentication mode to connect to the SQL Server database.

    Power Query SQL Server connection login credentials

    1. Windows: This is the default selection. Select this if you want to connect using Windows authentication.

    2. Database: Select this if you want to connect using SQL Server authentication. After you select this, specify a user name and password to connect to your SQL Server instance.

  6. By default, the Encrypt connection check box is selected to signify that Power Query connects to your database using an encrypted connection. If you do not want to connect using an encrypted connection, clear this check box, and then click Connect.

    If a connection to your SQL Server is not established using an encrypted connection, Power Query prompts you to connect using an unencrypted connection. Click OK in the message to connect using an unencrypted connection.

Formula Example

You can also use the Query Editor to write formulas for Power Query.

= Sql.Databases(".")
= Sql.Database(".","Contoso")

  1. Click the Power Query tab on the Ribbon, then select Get External Data > From Other Sources > From ODBC.

  2. In the From ODBC dialog, if displayed, select your Data Source Name (DSN).

  3. Enter your connection string, then press OK.

  4. In the next dialog box, select from Default or Custom, Windows, or Database connection options, enter your credentials, then press Connect.

  5. In the Navigator pane, select the tables or queries that you want to connect to, then press Load or Edit.

  1. In the Power Query ribbon tab, select From Database > From Access Database.

    Get data From Database dialog

  2. In the Browse dialog box, browse for or type a file URL to import or link to a file.

  3. Follow the steps in the Navigator dialog to connect to the table or query of your choice.

  4. Click Load or Edit.

  1. In the Power Query ribbon tab, click From File > From XML.

    Power Query From File dialog

  2. In the From XML Browse dialog box, browse for or type a file URL to import or link to a file.

  3. Click Open.

    After the connection succeeds, you will be able to use the Navigator pane to browse and preview the collections of items in the XML file in a tabular form.

You can also use the Query Editor to write formulas for Power Query. For example:

= Xml.Tables(File.Contents("C:DownloadsXML Example.xml"))

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

  1. On the Data tab, in the Get External Data group, click From Other Sources, and then click From Analysis Services.

    Excel  Ribbon Image

    The Data Connection Wizard is displayed. This wizard has three panes.

    • Connect to Database Server

    • Select Database and Table

    • Save Data Connection File and Finish

  2. In the Connect to Database Server pane, in the Server name box, type the name of the OLAP database server.

    Tip: If you know the name of the offline cube file that you want to connect to, you can type the complete file path, file name, and extension.

  3. Under Log on credentials, do one of the following, then click Next:

    • To use your current Windows user name and password, click Use Windows Authentication.

    • To enter a database user name and password, click Use the following User Name and Password, and then type your user name and password in the corresponding User Name and Password boxes.

  4. In the Select the database that contains the data you want pane, select a database, then click Next.

    To connect to a specific cube in the database, make sure that Connect to a specific cube or table is selected, and then select a cube from the list.

  5. In the Save Data Connection File and Finish pane, in the File Name box, revise the default file name as needed (optional).

    Click Browse to change the default file location of My Data Sources, or check for existing file names.

  6. In the Description, Friendly Name, and Search Keywords boxes, type a description of the file, a friendly name, and common search words (all are optional).

  7. To ensure that the connection file is used when the PivotTable is refreshed, click Always attempt to use this file to refresh this data.

    Selecting this check box ensures that updates to the connection file will always be used by all workbooks that use that connection file.

  8. Click Finish to close the Data Connection Wizard.

  9. In the Import Data dialog box, under Select how you want to view this data in your workbook, do one of the following:

    • To create just a PivotTable report, click PivotTable Report.

    • To create a PivotTable report and a PivotChart report, click PivotChart and PivotTable Report.

    • To store the selected connection in the workbook for later use, click Only Create Connection. This check box ensures that the connection is used by formulas that contain Cube functions that you create and that you don’t want to create a PivotTable report.

  10. Under Where do you want to put the data, do one of the following:

    • To place the PivotTable report in an existing worksheet, select Existing worksheet, and then type the cell reference of the first cell in the range of cells where you want to locate the PivotTable report.

      You can also click Collapse Dialog Button image to temporarily hide the dialog box, select the beginning cell on the worksheet that you want to use, and then press Expand Dialog Button image.

  11. To place the PivotTable report in a new worksheet starting at cell A1, click New worksheet.

  12. To verify or change connection properties, click Properties, make the necessary changes in the Connection Properties dialog box, and then click OK.

  1. On the Power Query tab, click From Other Sources > Blank Query.

  2. In the Query Editor, click Advanced Editor.

  3. Input your query string as follows, replacing «C:UsersNameDesktopJSONTest.json» with the path to your JSON file.

    let
    
        Source = Json.Document(File.Contents("C:UsersNameDesktopJSONTest.json")),
        #"Converted to Table" = Record.ToTable(Source)
    
    in
    
        #"Converted to Table"
    

  1. In the Power Query ribbon tab, click From Database > From Oracle Database.

    Power Query From Database options

  2. In the Oracle Database dialog box, in Server Name specify the Oracle Server to connect to. If a SID is required, this can be specified in the form of “ServerName/SID”.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

  4. Click OK.

  5. If the Oracle server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Connect.

  1. In the Power Query ribbon tab, select From Other Sources > From SharePoint List.

    Power Query get data from Other Sources dialog

  2. In the Microsoft SharePoint Lists dialog box that appears, enter the URL for a SharePoint site.

    Note: When connecting to a SharePoint list, enter the site URL instead of the list URL. In the Access SharePoint dialog box, select the most general URL to authenticate against the site correctly. By default, the most general URL is selected.

  3. Select OK to continue.

  4. In the Access SharePoint dialog box that appears next, select a credentials option:

    1. Select Anonymous if the SharePoint Server does not require any credentials.

    2. Select Windows if the SharePoint Server requires your Windows credentials.

    3. Select Organizational account if the SharePoint Server requires organizational account credentials.

  5. Select Connect.

    Excel Power Query connect to a Sharepoint List Connect dialog

  1. In the Power Query ribbon tab, select From Other Source > From OData Feed.

    Power Query get data from Other Sources dialog

  2. In the OData Feed dialog box, enter the URL for an OData feed.

  3. Select OK.

  4. If the OData feed requires user credentials, in the Access an OData feed dialog box:

    1. Select Windows if the OData feed requires Windows Authentication.

    2. Select Basic if the OData feed requires your username and password.

    3. Select Marketplace key if the OData feed requires a Marketplace account key. You can select the Get your Marketplace Account Key to subscribe to Microsoft Azure marketplace OData feeds. You can also Sign up for Microsoft Azure Marketplace from the Access an OData Feed dialog box.

    4. Click Organizational account if the OData feed requires federated access credentials. For Windows Live ID, log into your account.

    5. Select Save.

Note: Connect to an OData feed supports the JSON light data service format.

  1. Click the Data tab, then Get Data > From Other Sources > From OLEDB. If you don’t see the Get Data button, follow the Data Connection Wizard instructions below.

  2. In the From OLE DB dialog, enter your connection string, then press OK.

  3. In the OLEDB Provider dialog, select from the Default or Custom, Windows, or Database connection options, enter the appropriate credentials, then click Connect.

  4. In the Navigator dialog, select the Database and tables or queries you want to connect to, then press Load or Edit.

  5. In the Power Query Editor, press Close & Load.

  1. In the Power Query ribbon tab, click From Database > From MySQL Database.

    Power Query From Database options

  2. In the MySQL Database dialog box, in Server Name specify the MySQL Database Server to connect to.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

  4. Click OK.

  5. If the MySQL server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Connect.

  1. In the Power Query ribbon tab, select From Other Sources > From Microsoft Exchange.

    Power Query Data Sources

  2. In the Access an Exchange Server dialog box, specify your Email Address and Password.

  3. Click Save.

  4. In the Microsoft Exchange Autodiscover Service dialog box, select Allow to allow the Exchange Service to trust your credentials.

Important: Make sure you have downloaded and installed the Power Query Add-In.

  1. In the Power Query ribbon tab, click From Other Sources > From Active Directory.

    Power Query get data from Other Sources dialog

  2. Enter your domain in the Active Directory dialog box.

  3. In the Active Directory Domain dialog box for your domain, click Use my current credentials, or Use alternate credentials. For Use alternate credentials authentication, enter your Username and Password.

  4. Click Connect.

  5. After the connection succeeds, you can use the Navigator pane to browse all the domains available within your Active Directory, and drill down into Active Directory information including Users, Accounts, and Computers.

Warning: 

  • Before you can connect to an IBM DB2 database, you need the IBM DB2 Data Server Driver installed on your computer (minimum requirement is the IBM Data Server Driver Package (DS Driver)). Select the driver that matches your Power Query installation (32-bit or 64-bit).

  • There are known issues reported by IBM installing the IBM DB2 Data Server Driver on Windows 8. If you are using Windows 8 and want to connect to IBM DB2 using Power Query, you need to follow additional installation steps. Find more information about the IBM DB2 Data Server Driver on Windows 8.

  1. In the Power Query ribbon tab, click From Database > From IBM DB2 Database.

    Power Query From Database options

  2. In the IBM DB2 Database dialog box, in Server Name specify the IBM DB2 Database Server to connect to.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

  4. Click OK.

  5. If the IBM DB2 server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Connect.

Note: Before you can connect to a PostgreSQL database in Power Query, you need the Ngpsql data provider for PostgreSQL installed on your computer. Select the driver that matches your Office version (32-bit or 64-bit). See: Which version of Office am I using? for more information. Also make sure you have the provider registered in the machine configuration that matches the most recent .NET version on your device.

  1. In the Power Query ribbon tab, select From Database > From PostgreSQL Database.

    Power Query From Database options

  2. In the PostgreSQL Database dialog box, specify the PostgreSQL Database Server you want to connect to in the Server Name section.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

  4. Select OK.

  5. If the PostgreSQL server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Select Connect.

  1. Navigate to https://web.powerapps.com/

  2. Select the Environment you want to connect to.

  3. In the menu, select the Settings icon > Advanced customizations > Developer resources.

  4. Copy the Instance Web API value. 

    Notes: 

    • The url format will be something like https://<tenant>.crm.dynamics.com/api/data/v9.0.

    • The exact format of the URL you will use to connect depends on your region and the version of CDS for Apps you’re using. For more information see: Web API URL and versions (docs.com).

  5. Select the Data tab, then Get Data > From Online Services > From Dynamics 365 (online).

    • If you don’t see the Get Data button, click New Query > From Other Sources > From Dynamics 365 (online).

  6. In the dialog box, with the Basic option selected, enter the Web API URL for your CDS for Apps connection, and click OK.

    • If you select the Advanced option, you can append certain additional parameters to the query to control what data is returned. For more information see: Query Data using the Web API.

  7. Select Organization account.

    • If you aren’t signed in using the Microsoft Work or School account you use to access CDS for Apps, click Sign in and enter the account username and password.

  8. Click Connect.

  9. Within the Navigator dialog, select the data you want to retrieve.

  10. If the data is good to be imported as is, then select the Load option, otherwise choose the Edit option to open the Power Query Editor.

    Note: The Power Query Editor gives you multiple options to modify the data returned. For instance, you might want to import fewer columns than your source data contains. In that case, go to the Home tab > Manage Columns > Choose Columns, select the columns you want to keep, then click OK. When you’re ready, click Close & Load to return the modified data to Excel.

  1. In the Power Query ribbon tab, select From Database > From Teradata Database.

    Power Query From Database options

  2. In the Teradata Database dialog box, in Server Name specify the Teradata Server to connect to.

  3. If you want to import data using native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

  4. Select OK.

  5. If the Teradata server requires database user credentials:

    1. In the Access a Database dialog box, enter your username and password.

    2. Click Save.

Important: 
Retirement of Facebook data connector notice     Import and refresh data from Facebook in Excel will stop working in April, 2020. You will still be able to use the Facebook Get & Transform (Power Query) connector until then, but starting in April, 2020, you will be unable to connect to Facebook and will receive an error message. We recommend revising or removing any existing Get & Transform (Power Query) queries that use the Facebook connector as soon as possible to avoid unexpected results.

Note: If this is the first time you’ve connected to Facebook, you will be asked to provide credentials. Sign in using your Facebook account, and allow access to the Power Query application. You can turn off future prompts by clicking the Don’t warn me again for this connector option.

  1. In the Power Query ribbon tab, click From Other Sources > From Facebook.

  2. In the Facebook dialog box, connect to Facebook using “Me”, your Username, or Object ID.

    Note: Your Facebook username is different from your login email.

  3. Select a category to connect to from the Connection drop-down list. For example, select Friends to give you access to all information available in your Facebook Friends category.

  4. Click OK.

  5. If necessary, click Sign in from the Access Facebook dialog, then enter your Facebook email or phone number, and password. You can check the option to remain logged in. Once signed in, click Connect.

  6. After the connection succeeds, you will be able to preview a table containing information about the selected category. For instance, if you select the Friends category, Power Query renders a table containing your Facebook friends by name.

  7. Click Load or Edit.

You can use the Query Editor to write formulas for Power Query.

= Facebook.Graph("https://graph.facebook.com/v2.8/me/friends")

Power Query Editor with Facebook formula

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

Notes: 

  • Before you can connect to an SAP SQL Anywhere database, you need the SAP SQL Anywhere driver installed on your computer. Select the driver that matches your Power Query installation (32-bit or 64-bit).

  1. In the POWER QUERY ribbon tab, select From Database > From SAP Sybase SQL Anywhere.

    Get External Data from a Database

  2. In the Sybase Database dialog box, specify the Sybase Server to connect to in the Server Name box. Optionally, you can specify a Database Name as well.

  3. If you want to import data using a native database query, specify your query in the SQL Statement box. For more information, see Import Data from Database using Native Database Query.

  4. Click OK.

  5. By default, the Encrypt connection check box is selected so that Power Query connects to your database using a simple encrypted connection.

  6. Click Connect.

Microsoft Azure Blob Storage is a service for storing large amounts of unstructured data, like images, videos, audio, and documents, which can be accessed from anywhere in the world via HTTP or HTTPS. For more information about Azure Blob Storage service, see How to Use Blob Storage.

  1. In the Power Query ribbon tab, select From Azure > From Microsoft Azure Blob Storage.

    Power Query Import from Azure dialog

  2. In the Microsoft Azure Blob Storage dialog box, enter your Microsoft Azure storage account name or URL, and then click OK.

  3. If you are connecting to the Blob storage service for the first time, you will be prompted to enter and save the storage access key. In the Access Microsoft Azure Blob Storage dialog box, enter your storage access key in the Account Key box, and click Save.

    Note: If you need to retrieve your storage access key, browse to the Microsoft Azure Portal, select your storage account, and then click on the Manage Access Key icon on the bottom of the page. Click on the copy icon to the right of the primary key, and then paste the value in the Account Key box.

  4. The Query Editor lists all the available containers in your Microsoft Azure Blob Storage. In the Navigator, select a container from where you want to import data, and then click Apply & Close.

  1. In the POWER QUERY ribbon tab, select From Azure > From Microsoft Azure HDInsight.

    Get external data from Azure

  2. In the Microsoft Azure HDInsight dialog box, enter an Account Name and click OK.

  3. Next, enter your Account Key, and click Connect.

    Note: If you need to retrieve your key, return to the Microsoft Azure Portal, select your storage account, and click on the Manage Access Key icon on the bottom of the page. Click on the copy icon to the right of the primary key and paste the value into the wizard.

  4. Select your cluster in the Navigator dialog, and then find and select a content file.

  5. Click Load to load the selected table, or click Edit to perform additional data filters and transformations before loading it.

If you are a developer, there are several approaches within Excel that you can take to import data:

  • You can use Visual Basic for Applications to gain access to an external data source. Depending on the data source, you can use either ActiveX Data Objects or Data Access Objects to retrieve the data. You can also define a connection string in your code that specifies the connection information. Using a connection string is useful, for example, when you want to avoid requiring system administrators or users to first create a connection file, or to simplify the installation of your application.

  • If you import data from an SQL Server database, consider using SQL Native Client, which is a standalone data access Application Programming Interface (API) that is used for both OLE DB and ODBC. It combines the SQL OLE DB Provider and the SQL ODBC Driver into one native, dynamic link library (DLL), while also providing new functionality that is separate and distinct from the Microsoft Data Access Components (MDAC). You can use SQL Native Client to create new applications or enhance existing applications that can take advantage of newer SQL Server features, such as Multiple Active Result Sets (MARS), User-Defined Types (UDT), and XML data type support.

  • The RTD function retrieves real-time data from a program that supports COM automation. The RTD COM automation add-in must be created and registered on a local computer.

  • The SQL.REQUEST function connects with an external data source and runs a query from a worksheet. The SQL.REQUEST function then returns the result as an array without the need for macro programming. If this function is not available, you must install the Microsoft Excel ODBC add-in program (XLODBC.XLA). You can install the add-in from Office.com.

For more information about creating Visual Basic for Applications, see Visual Basic Help.

See Also

Power Query for Excel Help

Import data from database using native database query

Use multiple tables to create a PivotTable

Import data from a database in Excel for Mac

Getting data (docs.com)

Windows 10 with MS Excel (Office 365) and PostgreSQL 11

This short HOWTO explains the steps to connect MS Excel 2016 to a PostgreSQL database.

At the time of writing, the PostgreSQL database was running version 11.1 in a Docker container (outside the scope of this HOWTO).

To follow this HOWTO you will need a PostgreSQL server to connect to. The examples shown are based on the DVD Rental sample database.

Installing Required Software

Assuming Windows 10 is already installed, you need to install the following additional software:

  • Microsoft Office 365 — follow the instructions as per Microsoft. Note: Registration required.
  • PostgreSQL ODBC Drivers for Windows

Installing the ODBC Drivers

  1. Download the 32bit drivers. Note: The 64bit driver will not work with MS Excel, which is only a 32bit application!
  2. Unzip in a convenient location on your local machine
  3. Navigate into the unzipped folder and run the installer

Configuring the ODBC Data Source

Windows 10 ships with ODBC utilities. Follow these simple instructions:

Step # Screenshot Description
1 On the Start page, type «ODBC Data Sources» (without the quotes)
2 On the «Use DSN» Tab, click the «Add…» button
3 Select «PostgreSQL ANSI»
4 On the next window, enter the database connections details. Use the «Test» button to test your connection!
5 Once done, you should see the new data source is now available

Connecting to the Data Source in MS Excel 2016

Step # Screenshot Description
1 Assuming you have opened MS Excel, navigate to the «Data» tab and click on «Existing Connections»
2 In the open dialog box, click on «Browse for more…» button (bottom left corner)
3 In the next dialog, open the «Connect to New Data Source.odc» option.
4 In the next dialog box select «ODBC DSN» and click the «Next» button
5 Now select your «DVD_Rental» database (depending on what you named it), and click «Next»
6 Select a table you whish to connect to, for example «actor», and click «Next»
7 Select where you want to save the data source details. WARNING: Saving your database credentials may pose a risk. Use with caution and in accordance with your company security policies!
8 Once you click the «Finish» button, you will now have to select how you want to import the data — this choice is up to you! Experiment!
9 Your data is now imported and linked!

Conclusion

This was a very quick HOWTO that walked through the steps of connecting MS Excel 365 running on Windows 10 to a PostgreSQL 11.1 Database (using a sample database).

Here is how to connect to the PostgreSQL database with Excel or Power BI using the ODBC data source.

First of all, you will need:
– Hostname or IP address (server).
– PostgreSQL database name and specified port.
– Database username and password.

Follow these steps to connect to the PostgreSQL database with Excel or Power BI

1. Download and install PostgreSQL ODBC driver.

2. Check the bit version of your Excel or Power BI. That is important to configure your ODBC data source properly.

In Excel go to File -> Account -> Click on About Excel icon.

In Power BI go to Help -> About.

3. Click on the Windows start button and type “odbc” and choose the right bit version of ODBC Data sources.

4. In the ODBC Data Source Administration window, click on the Add button and find the previously installed Postgre SQL driver.

PostgreSQL Windows ODBC data sourc

5. Fill down all the necessary information. You can freely choose Data Source and Description. Other information should be given by your administrator.

PostgreSQL Windows ODBC data source setup

6. Click on the Test button. If everything is good, then there is information that the connection is successful. If it is not, then check some of the possible errors below.

Connect to PostgreSQL with Excel or Power BI

In Excel go to the Data tab, click on Get Data -> From Other Sources -> From ODBC and choose your previously created ODBC data source.

PostgreSQL-Excel

PostgreSQL error: no pg_hba.conf entry for host

If the PostgreSQL user is not configured properly, then you might get this error. Please contact your administrator.

PostgreSQL error: pgbouncer cannot connect to server

Some of your connection parameters might be incorrect. For example, check the spelling of your database name. If that doesn’t help, contact your administrator.

By the way – did you know this Excel trick? Convert TRUE and FALSE values to 1 and 0 in Excel

Here is some interesting analytics that you can do in Power BI – How to identify outliers in Microsoft Power BI.

Asked
10 years, 5 months ago

Viewed
44k times

Is it possible to make query like SELECT from VBA in Excel, so I can query a PostgreSQL DB from Excel?

If is possible please explain me how to connect to the database. I was looking in Google but found no results.

Craig Ringer's user avatar

Craig Ringer

301k72 gold badges675 silver badges759 bronze badges

asked Nov 5, 2012 at 10:44

vivid's user avatar

Community's user avatar

answered Nov 5, 2012 at 10:56

Craig Ringer's user avatar

Craig RingerCraig Ringer

301k72 gold badges675 silver badges759 bronze badges

Here’s some code can use as reference. Hope it helps.

Sub SelectBasic()

        Dim objDb_con
        Dim strSomeValue As String

        Set objDb_con = CreateObject("ADODB.Connection")
        Set Rsdatatype = CreateObject("ADODB.RecordSet")

        glbConnString = Trim(ActiveSheet.Range("B1").Value)
        //Connection string format:Driver={PostgreSQL Unicode};Database=MyDB;server=192.16*.*.**;UID=USERID;Pwd=pasword //comment it
        If glbConnString = "" Then
         MsgBox "Enter the Connection String"
        Else:

        objDb_con.Open glbConnString

        strSql = "select strSomeValue  from SOMETABLE where Something=1"
        Rsdatatype.Open strSql, objDb_con, adOpenKeyset, adLockpessimistic
        If Rsdatatype.EOF = False Then strSomeValue = Rsdatatype.Fields(0).Value
        Rsdatatype.Close

        End If
        objDb_con.Close
    End Sub

answered Nov 5, 2012 at 11:20

subZero's user avatar

subZerosubZero

3071 silver badge9 bronze badges

0

Понравилась статья? Поделить с друзьями:
  • Excel conditional formatting icon
  • Excel conditional formatting formula if and or
  • Excel conditional formatting format
  • Excel conditional formatting for table
  • Excel conditional formatting and rule