Json file from excel

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)

To Parse Custom JSON data is to split out its name/value pairs into a more readable useable format.

Excel is a powerful tool that allows you to connect to JSON data and read it.  However sometimes this data might require a little manipulation to be fully understood and analysed in Excel. 

In this article you will learn

  • What is JSON Data
  • To Connect to JSON data from Excel
  • How to Parse simple JSON Data using Excels Power Query
  • To Parse complex JSON Data using Excels Power Query

This article contains data tables to download so you can practice along and master the art of parsing custom JSON data using Excel.  We are also powered with STEEM so you can earn while you learn 😊.  If you are not familiar with Excel Power Tools you can find out about them here.

What is JSON Data?

JSON data is a way of representing objects or arrays.  It is easy to read, and it is easy to parse, even with Excel.  Many API calls will return JSON format and many web apps use JSON which easily moves information around the internet.

The syntax for JSON comes from JavaScript and can be summarized as follows:

  • Data is shown in name/value pairs separated by : For example “name” : ”paulag”
  • Data is separated by commas. For Example “name” : ”paulag” , “Sex” : “Female”
  • Curly brackets represent an object. An object being a name/value pair separated by a comma. For Example {“name” : ”paulag” , “Sex” : “Female”}
  • Square brackets hold arrays and contains a list of values separated by a comma.

Look at the sample JSON in the image below

How to Parse Custom JSON Data using Excel

{“total_population”: This shows the first object, which is a name/value pair.  The name of the object is total_population

[{“date”: “2019-01-02”, “population”: 7638335801}, {“date”: “2019-01-03”, “population”: 7638557789}]}  This is the value for the total population. The [ represents an array.  This array contains two objects. The objects are defined within the curly brackets and separated with a comma. Each object contains 2 lots of data (name/value pair) also separated with a comma.  The data, shown in the name/value pairs, in this example is date and population.

Here is one you can look at yourself. https://api.coinmarketcap.com/v1/ticker/bitcoin/

If you enter this to your browser, you will get something like the below:

excel JSON

Let’s take a look at that image in more detail.

Connecting to JSON data from Excel

In Excels Data ribbon, under GET and Transform Data, we have the option of connecting to data of multiple sources and multiple types. 

If we select Get data from file, we will then have the option to get data from a JSON file. 

In this example we have URL API endpoint https://api.coinmarketcap.com/v1/ticker/bitcoin/.  Therefore, from the Data Ribbon we can select, Get data from Web.  This will open a dialogue box in which you place the URL.

Next, Power query will then open.  Power query is a magic excel tool that will allow you transform data that you connect to into a usable format.

The JSON data will appear as a list of records Power Query. For excel to read this, we must convert a list to a table. Select ‘to table’ from the available option.

Next, Power query will create a table and you will see this step appear on the right of the power query window under applied steps. 

This new table contains a record. We must expand this record to get the value pairs. As this record only has 1 row, we would expect this to expand across the columns.  To do this, right click on the arrows in the column header.

This will reveal the names of the value pairs.  By selecting ok a new column will be set up in the table.  The name will be in the header and the value in the row.  

Further transformations

If we wanted this data going down the row, we could Unpivot the columns.  By selecting the id column.  Then from the Transform ribbon select the dropdown for unpivot columns and select unpivot other columns. 

When working with Power Query, it’s important to make sure you have the correct data types set.  To work with this data, we must now move to from Power Query to Excel.  If we select File, and then select Close and load, this will load the data as a table in Excel.  Or, if we select or Close and Load to, the data will be loaded into a Power Pivot Model.  

How to Parse JSON Data in Excel

Very often when you access JSON data with Excel it appears in 1 column.  This can happen for many reasons and is often the design of a database.

Look at the image below.  We can see the json_metadata field is still in its JSON syntax

How to Parse Custom JSON Data using Excel

When we encounter data like this, we can easily parse the column into its components.  From the image below we see we have 4 components. We have An Array, an Object, the data, and one of the data fields contains an array.

How to Parse Custom JSON Data using Excel

STEP by STEP

Download this file.  It contains a table as shown below.  (do not copy and paste the table as the JSON field will not be recognised.) 

tx_id

tid

json_metadata

timestamp

647524676

follow

[“follow”,{“follower”:”mervin-gil”,”following”:”jarvie”,”what”:[“blog”]}]

43466.89097

647524682

follow

[“follow”,{“follower”:”steliosfan”,”following”:”michealb”,”what”:[“blog”]}]

43466.89097

647524833

follow

[“follow”,{“follower”:”eugenezh”,”following”:”zentricbau”,”what”:[“blog”]}]

43466.89097

647524855

follow

[“follow”,{“follower”:”bitcoinportugal”,”following”:”manuellevi”,”what”:[]}]

43466.89097

647525074

follow

[“follow”,{“follower”:”eugenezh”,”following”:”adriellute”,”what”:[“blog”]}]

43466.89167

647525089

follow

[“follow”,{“follower”:”bigbigtoe”,”following”:”hoxly”,”what”:[“blog”]}]

43466.89167

647525121

follow

[“follow”,{“follower”:”mervin-gil”,”following”:”loveon”,”what”:[“blog”]}]

43466.89167

647525159

follow

[“follow”,{“follower”:”mervin-gil”,”following”:”pechichemena”,”what”:[“blog”]}]

43466.89167

647525233

follow

[“follow”,{“follower”:”imealien”,”following”:”pataty69″,”what”:[“blog”]}]

43466.89167

647525652

follow

[“follow”,{“follower”:”mervin-gil”,”following”:”kamile”,”what”:[“blog”]}]

43466.89236

647525818

follow

[“follow”,{“follower”:”bitcoinportugal”,”following”:”drmake”,”what”:[“blog”]}]

43466.89236

647525886

follow

[“follow”,{“follower”:”mervin-gil”,”following”:”bradfordtennyson”,”what”:[“blog”]}]

43466.89236

647525980

follow

[“follow”,{“follower”:”a0i”,”following”:”shoemanchu”,”what”:[“blog”]}]

43466.89236

647526007

follow

[“follow”,{“follower”:”voteme”,”following”:”kostyantin”,”what”:[“blog”]}]

43466.89236

648215552

follow

[“follow”,{“follower”:”ansie”,”following”:”hoxly”,”what”:[“blog”]}]

43467.75833

648215582

follow

[“follow”,{“follower”:”ashokcan143″,”following”:”abcor”,”what”:[]}]

43467.75833

648215691

follow

[“follow”,{“follower”:”ashokcan143″,”following”:”abasinkanga”,”what”:[]}]

43467.75903

648215820

follow

[“follow”,{“follower”:”nongvo.piy”,”following”:”acidyo”,”what”:[]}]

43467.75903

648215859

follow

[“follow”,{“follower”:”grid9games”,”following”:”yeninsfer”,”what”:[“blog”]}]

43467.75903

648215945

follow

[“follow”,{“follower”:”nongvo.piy”,”following”:”acidyo”,”what”:[“blog”]}]

43467.75903

Click on any of the cells that contain the data and from the Data Ribbon select FROM Table/Range

How to Parse Custom JSON Data using Excel

If your data is not in table format, Excel will then prompt you to create a table.  Select the cells the contain the data and tick the box to say that your table has headers.

How to Parse Custom JSON Data using Excel

Power Query editor window will open. On the canvas you can see your data and, on the right, you can see any transformation steps that have taken place.

How to Parse Custom JSON Data using Excel

To parse the json column, first select the column, then on the Transform Ribbon select Parse and select JSON

How to Parse Custom JSON Data using Excel

Power query will recognise the first [ and create a list format.  Next, we need to expand this list to new rows.  To do this click on the arrows on the top of the column and select Expand to New Rows.

How to Parse Custom JSON Data using Excel

What is returned is two lines for each tx-id.  The json column now has a row for the name of the array, which is follow, and a record.  The record will contain the data.

How to Parse Custom JSON Data using Excel

As we do not need the name of the array, we can use the filter to remove all the follow rows

How to Parse Custom JSON Data using Excel

We are now left with the records. We can expand this record, by pressing the arrow on the column.  From here we see we have the names of 3 data fields, Follower, Following and What

How to Parse Custom JSON Data using Excel

When we select OK, we get a new column in our data table for each data field.

However, the field named what contains an array, which is again shown as a list (or array) which needs to be expanded

How to Parse Custom JSON Data using Excel

Once we expand this, we are at the end of the JSON data and have extracted the relevant columns.  You can now use this data for further analysis in Excel or Power Pivot.  To load it back to excel, select File and Close & Load.

How to Parse Custom JSON Data using Excel

More complex JSON data extractions in Excel

So far, we have looked at getting JSON data into Power Query using an Excel table and directly from a URL.  There are other ways you can connect to JSON data including connecting directly to a JSON file.  Connecting is the easy part.  Things get more complicated when you have JSON columns where the strings are different in each row.  One might start with an array and so return a list, but some might start with an object and return a record.  

In Power Query lists are expanded to new rows in the table and records are expanded to new columns. Parsing custom JSON data in Excel can require some thinking.

JSON (Javascript Object Notation) is the most used data exchange format nowadays. Microsoft Excel doesn’t have built-in support for importing JSON to excel or exporting excel data to JSON.

VBA-JSON is an excellent library for parsing JSON in VBA. Lets see how to handle JSON in Excel VBA. If you’re new to JSON then read JSON tutorial for beginners

Prerequisites

  1. Save your excel file as Macro-Enabled workbook (Refer screen shot below)
  2. Enable macros if they are not already enabled. You can enable it by cliking on file > options > Trust Center > Trust Center Settings > Enable all macros

Save as xlsm
Enable excel macros

Getting Started

  1. Download VBA JSON latest version from here
  2. Extract it, open VBA code editor in excel (Alt + F11) and import the library as shown in the gif below.
  3. Add a reference to Microsoft scripting runtime. (Tools > references > select)
  4. Add a reference to MSXML (Tools > references)
    Select appropriate version based on your PC :
    1. Microsoft XML, v 3.0.
    2. Microsoft XML, v 4.0 (if you have installed MSXML 4.0 separately).
    3. Microsoft XML, v 5.0 (if you have installed Office 2003 – 2007 which provides MSXML 5.0 for Microsoft Office Applications).
    4. Microsoft XML, v 6.0 for latest versions of MS Office.

excel to json
Add reference microsoft xml and scripting runtime excel

Import JSON to Excel

This library provides a simple method ParseJson to parse JSON string into a dictionary object which can be used to extract data. Let’s see an example.

I’m using fake data from http://jsonplaceholder.typicode.com/ which is an API service with fake Json data.

We’ll be pulling user data from http://jsonplaceholder.typicode.com/users by making a GET request which responds with Json data.

json sample data - json to excel

Read more about GET requests in VBA here

Next, we’ll parse that Json and import it to excel. Code for importing data looks like this :

Public Sub exceljson()
Dim http As Object, JSON As Object, i As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "http://jsonplaceholder.typicode.com/users", False
http.Send
Set JSON = ParseJson(http.responseText)
i = 2
For Each Item In JSON
Sheets(1).Cells(i, 1).Value = Item("id")
Sheets(1).Cells(i, 2).Value = Item("name")
Sheets(1).Cells(i, 3).Value = Item("username")
Sheets(1).Cells(i, 4).Value = Item("email")
Sheets(1).Cells(i, 5).Value = Item("address")("city")
Sheets(1).Cells(i, 6).Value = Item("phone")
Sheets(1).Cells(i, 7).Value = Item("website")
Sheets(1).Cells(i, 8).Value = Item("company")("name")
i = i + 1
Next
MsgBox ("complete")
End Sub

Code explanation

  1. First, define JSON as an object and make a GET request to JSON API
  2. JSON data received in the response is parsed by passing it into ParseJson method.
  3. parsed data is converted into a collection of dictionaries.
  4. Loop through the collection to get each user’s details and set its values to the first sheet.

Running above code looks like gif below.

import json demo - json to excel

Reading JSON from a file

In the same example above, If you want to read JSON data from a local file then you can use FileSystemObject to read all text in the file and then pass it to ParseJson method.

Dim FSO As New FileSystemObject
Dim JsonTS As TextStream
Set JsonTS = FSO.OpenTextFile("example.json", ForReading)
JsonText = JsonTS.ReadAll
JsonTS.Close
Set JSON = ParseJson(JsonText)

Export Excel to Json

VBA-JSON provides another method ConvertToJson which can be used to convert excel data into JSON. Here’s an example.

Sample data with Name, Phone and Email is present in second sheet. Let’s convert it into JSON

Code for this looks like :

Public Sub exceltojson()
Dim rng As Range, items As New Collection, myitem As New Dictionary, i As Integer, cell As Variant
set rng = Range("A2:A3")
'Set rng = Range(Sheets(2).Range("A2"), Sheets(2).Range("A2").End(xlDown)) use this for dynamic range
i = 0
For Each cell In rng
Debug.Print (cell.Value)
myitem("name") = cell.Value
myitem("email") = cell.Offset(0, 1).Value
myitem("phone") = cell.Offset(0, 2).Value
items.Add myitem
Set myitem = Nothing
i = i + 1
Next
Sheets(2).Range("A4").Value = ConvertToJson(items, Whitespace:=2)
End Sub

Code Explanation

  1. First, define rng as range and set it to data range.
  2. ConvertToJson method takes a dictionary collection or array as parameter. So we should pass our data as a collection.
  3. A Dictionary is an object with keys and values just like JSON but doesn’t support multiple items like arrays or collections, so we create a dictionary for each item and push it into an array or a collection.
  4. Define a dictionary and a collection, loop through the range and set each row’s data into myitem
  5. Push myitem into collection and set it to nothing, because we are using the same dictionary to add next row’s data and push it to collection again.

Finally pass items collection to ConvertToJson method which returns a JSON string.

Running above code looks like gif below

export excel to json

Export Excel to JSON file

In the same example above, If you want to export excel data to JSON file then It can be done by opening a file for output by specifying the path of the file and printing data in it. Sample code below, Running this would save a JSON file in the current workbook’s folder.

Public Sub exceltojsonfile()
Dim rng As Range, items As New Collection, myitem As New Dictionary, i As Integer, cell As Variant, myfile As String
Set rng = Range("A2:A3")
'Set rng = Range(Sheets(2).Range("A2"), Sheets(2).Range("A2").End(xlDown)) use this for dynamic range
i = 0
For Each cell In rng
Debug.Print (cell.Value)
myitem("name") = cell.Value
myitem("email") = cell.Offset(0, 1).Value
myitem("phone") = cell.Offset(0, 2).Value
items.Add myitem
Set myitem = Nothing
i = i + 1
Next
myfile = Application.ActiveWorkbook.Path &amp;amp; "data.json"
Open myfile For Output As #1
Print #1, ConvertToJson(items, Whitespace:=2)
Close #1
End Sub

Export Excel to Nested JSON

Above code can be modified a bit to get a nested JSON as output. Just add dictionary in another dictionary so that it creates a nested JSON. code looks like this :

Public Sub exceltonestedjson()
Dim rng As Range, items As New Collection, myitem As New Dictionary, subitem As New Dictionary, i As Integer, cell As Variant
Set rng = Range("A2:A3")
'Set rng = Range(Sheets(2).Range("A2"), Sheets(2).Range("A2").End(xlDown)) use this for dynamic range
i = 0
For Each cell In rng
Debug.Print (cell.Value)
myitem("name") = cell.Value
myitem("email") = cell.Offset(0, 1).Value
myitem("phone") = cell.Offset(0, 2).Value
subitem("country") = cell.Offset(0, 3).Value
myitem.Add "location", subitem
items.Add myitem
Set myitem = Nothing
Set subitem = Nothing
i = i + 1
Next
Sheets(2).Range("A4").Value = ConvertToJson(items, Whitespace:=2)
End Sub

Running above code looks like image below

export excel to nested json

Using array of strings and objects in JSON

One of our readers asked me how to use an array of strings and objects inside the JSON.

Here’s how to do it:

Public Sub exceltojson()
Dim rng As Range, items As New Collection, myitem As New Dictionary, i As Integer, cell As Variant, objectContainer As New Dictionary, arrayContainer As New Collection
Dim j As Integer
'Set rng = Range("A2:A3")
Set rng = Range(Sheets(1).Range("A2"), Sheets(1).Range("A2").End(xlDown)) 'use this for dynamic range
i = 0
For Each cell In rng
myitem("id") = cell.Value
myitem("name") = cell.Offset(0, 1).Value

'tags
tagsString = cell.Offset(0, 2).Value
tagsCollection = getCollectionFromString(tagsString)
myitem.Add "tags", tagsCollection

'ingredients
ingredientsString = cell.Offset(0, 3).Value
weightsString = cell.Offset(0, 4).Value
ingredientsUnit = cell.Offset(0, 5).Value
ingredientsCollection = getCollectionFromString(ingredientsString)
weightsCollection = getCollectionFromString(weightsString)

j = 0
For Each ingredient In ingredientsCollection
objectContainer("ingredientnaam") = ingredient
objectContainer("eenheid") = ingredientsUnit
objectContainer("hoeveelheid") = weightsCollection(j)
arrayContainer.Add objectContainer
Set objectContainer = Nothing
j = j + 1
Next
myitem.Add "ingredienten", arrayContainer

'Reset values
Set arrayContainer = Nothing
j = 0

items.Add myitem
Set myitem = Nothing
i = i + 1
Next
Sheets(1).Range("A6").Value = ConvertToJson(items, Whitespace:=2)
End Sub

Function getCollectionFromString(val)
getCollectionFromString = Split(val, ", ")
End Function

Running above code looks like image below
export excel to nested json

Wrapping up

Read official documentation of VBA-JSON here and use VBA-Dictionary for Mac Support.

Related articles :

  • Complete JSON tutorial here – JSON for beginners
  • Handling CSV in VBA

If you have any questions or feedback, comment below and please use CodingisLove Bin for sharing your code.

  • Author
  • Recent Posts

A CA- by education, self taught coder by passion, loves to explore new technologies and believes in learn by doing.

What is JSON?

JSON (JavaScript Object Notation) is a file format that is used for storing and exchanging data in the network. It is used to send data from server to client and client to server.  JSON is easy for machines to analyze and generate. The extension of JSON  is .json. 

JSON records are, in reality, straightforward to peruse on the off chance that you know the construction of a Javascript document. You can utilize a proofreader with explicit help for JSON to get the disentangling. For instance, if there is an extremely pleasant JavaScript addon for Notepad++ called JSTool, which incorporates a JSON watcher, it shows the decoded esteem strings so you can duplicate the string to another content record. 

Check Out upGrad’s Java Bootcamp

A commonplace JSON record is a word reference where every section has a string key, and each worth is a string, a number, or exacting like valid, bogus or invalid. The qualities are strings that are encoded by the shows of Javascript, which is practically equivalent to Java or C, implying that every typical character is composed with no guarantees and all extraordinary characters are encoded with an oblique punctuation line.

This is either followed by the scorch that is implied or by a hex number that addresses the ASCII or Unicode estimation of the singe. For example, on the off chance, you have French or Spanish scorches or dialects that are totally outside Latin letters in order like Russian or Chinese. 

JSON is JavaScript object documentation or a progression of JavaScript objects with recorded credits. These credits are what is recorded within each set of wavy sections and give data about the object. JSON records may contain numerous objects in each document. They might be the consequence of an information dump from a program that utilizes JSON documentation or methods by which a client can enter data into a data set. MongoDB, for instance, locally utilizes JSON to store information. 

A JSON document is a record that stores straightforward information constructions and objects in JavaScript Object Notation (JSON) design, which is a standard information trade design. It is principally utilized for sending information between a web application and a server. JSON documents are lightweight, text-based, comprehensible, and can be altered by using a content manager. 

Also, check out our free courses to get an edge over the competition.

Open the record in Notepad, save it as a .TXT document, and then import it into Excel.

The Structure of JSON is 

Filename = [{key: value}]

Example

JSONExample ={ “namelist” : [ {name:”mark”, age:18, location:” Mars”},

{name:Steve Rogers, age:118, location:”Moon”},

{name:”Tony”, age:48, location:”DC”},

{name:”Peter Parker”, age:18, location:”Queens”},

{name:”Thor”, age:18, location:”Ascord”} ],

“id”:1

}

Applications of JSON

  • JSON files are primarily used while writing programming code in Javascript-based programs like node, react, etc.
  • The JSON file is used for transmitting data in a structured way while transferring via a network.
  • Most of the time JSON is used to transfer data between server and client applications.
  • In the modern era, JSON overtakes XML in the maximum amount.
  • It can adapt to all programming languages.

upGrad’s Exclusive Software and Tech Webinar for you –

Check Out upGrad’s Advanced Certification in Cyber Security

SAAS Business – What is So Different?

What is Excel?

Excel is the name of a software program created by Microsoft and is known as Microsoft Excel. It uses a spreadsheet to store the data and numbers with the functions and formulas. The extension of the excel file is .xlsx. It is widely used in the business sector.

There are important things about excel that you can learn at upGrad. Excel is perhaps the most remarkable measurement software. It permits you to store the information in even arrangement, i.e., in lines and segment design. It additionally allows you to collaborate with your data differently. 

You can sort and channel the information utilizing probably the most powerful equations. The turntables one is the best component of Excel. You can use turntables to make another understanding by controlling the information. Excel has different highlights that can assist you with insights. There are different approaches to bringing in and sending out the information. You can likewise incorporate the data into the work process. 

Like no different insight software, Excel permits you to make the custom capacity utilizing its programming capacities. The basic role of Excel is to make records of information and to control the information according to the users’ requests. As referenced before, Excel permits you to utilize the outside information base to dissect and make reports, among other things. 

Currently, Excel offers the best graphical UI alongside the utilization of design instruments and representation strategies.

Source 

Applications of Excel

1. Easy to Utilize Interface

MS Excel has an easy-to-use interface that empowers the client to utilize the software effectively without battling an excessive amount to keep up any records. 

2. Graphical Representation

MS Excel empowers the client to graphically address the information entered. This component of excel helps break down the numbers easily when we manage an enormous amount of data. When handling a vast amount of data (extending to 1000 lines), graphical representation helps us assess the information quickly. 

3. Highly Supportive in Breaking Down Deals

Excel helps organizations break down deals and buys and appropriately assists them with examining their purchasing/selling choices. 

Our learners also read: Excel online course free!

4. Financial Modeling 

Quite possibly, the main benefit of Excel is that it simplifies the financial analysis of the organization. It helps with maintaining the financial records of the organization in an easily accessible format. Excel is often used to calculate or determine EBITDA, WACC, net sales, and net profits, among other things.

5. Accessibility of a Broad Scope of Functions

Excel has enormous scope for doing equations which assists us with computing the entirety, item, difference, and any arrangements of numbers. The user can call upon various functions to simplify the vast data at hand to offer an accurate deduction.

6. Future Development of Any Business 

Excel is a valuable instrument to break down different sorts of information. Organizations use Excel to get an accurate picture of their business development and get a realistic forecast of the coming years’ achievable growth. Excel helps organizations accomplishing a particular development rate by examining the progress of the business.

How to Open JSON file in EXCEL?

The methods of opening JSON files in Excel vary in different versions of Microsoft Excel. You can apply the following methods to open a JSON file depending on the versions of Excel you have:

Office 2007

In the 2007 version of Office, excel doesn’t have the option to open a JSON file in EXCEL.

Office 2010

  • After opening Excel, on the Power Query tab, click From Other Sources > Blank Query.
  • In the Query Editor, click Advanced Editor.
  • Input your query string as follows, replacing “C:UsersNameDesktopexample.json” with the path to your JSON file.

let

    Source = Json.Document(File.Contents(“C:UsersNameDesktopexample.json”)),

    #”Converted to Table” = Record.ToTable(Source)

in

    # “Converted to Table”

Office 2013

In the 2013 version of Office, excel doesn’t have the option to open a JSON file in EXCEL.

  • After opening Excel, on the Power Query tab, click From Other Sources > Blank Query.
  • In the Query Editor, click Advanced Editor.
  • Enter your query string as follows, replacing “C:Usersexample.json” with the path to your JSON file.

let

    Source = Json.Document(File.Contents(“C:Usersexample.json”)),

    #”Converted to Table” = Record.ToTable(Source)

in

    # “Converted to Table”

In Newer Version of Excel

  • Select Data > Get Data > From File > From JSON. The Import Data dialog box appears.
  • Search the JSON file, and then select Open.

Opening JSON From the Internet in Excel

The above methods are used for opening files stored in local storage. If you want to import JSON data from the internet or from an API call, you can do the following:

  • Go to Data Tab -> Transform data -> Click From Web. It will open a window or modal.

Source

  • Then, open the power query.

Source

  • Next, create a table for the JSON.

Source

  • By following the steps, you can open the JSON file in EXCEL.

Learn Software Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.

Conclusion

JSON (JavaScript Object Notation) is a file format that is used in storing data and exchanging data in the network. EXCEL uses a spreadsheet to store the data and numbers with functions and formulas. The steps for opening a JSON file in Excel differ in several versions of EXCEL. In the newer version, you can open a JSON file by selecting “Data” > Get Data > From File > From JSON. The Import Data dialogue box appears. Search the JSON file, and then select “Open.” You can check out Free online Excel courses offered by upGrad on Excel

If you’re interested to learn more about full-stack development, check out upGrad & IIIT-B’s Executive PG Program in Full-stack Software Development which is designed for working professionals and offers 500+ hours of rigorous training, 9+ projects and assignments, IIIT-B Alumni status, practical hands-on capstone projects & job assistance with top firms.

What is a json format?

JSON is a format of storing and exchanging data. It stands for JavaScript Object Notation. JSON is a lightweight data-interchange format. It is used primarily to transmit data between a server and web application, as an alternative to XML. It is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. This data interchange format is simple, small, and language independent JSON was derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. It has become quite popular for transporting data between the server and web application. It is considered as a lightweight or language independent alternative to XML and is used in numerous AJAX applications.

How to view json files?

JSON file is actually a text file, you can view it line by line with simple text editor like notepad, notepad++ or emacs and so on. If you want to view it in python, it’ll be better to install jq, in that case, you can view it in python like: jq ‘.result’. There are many available JSON libraries for almost every language. If you are interested in Java, you may want to check out GSON. If you want to use for Python, you can also use simplejson.

What are the applications of JSON files?

JSON files are files that store data in JavaScript Object Notation. This is a lightweight format for storing data which is easy for humans to read and write. One of the best features of JSON files is that they are readable by both machines and humans (unlike XML) and more importantly, they work well with JavaScript. JSON files are commonly used for data-driven web applications. In fact, you can even use them to make a web page dynamic. JavaScript has the ability to parse these files and that’s why JSON is one of the best ways to return data to a web page. You can store data in a well-organized and easily-readable format.

Want to share this article?

Land on Your Dream Job

The users have different requirements, e.g., convert the excel data to JSON format. It needs to do the mapping of Excel worksheet columns to object keys. An Excel to JSON converter helps to convert the .xls file data to .JSON file format.

These Excel files can contain text, charts, graphs, formatting, functions, and more data.

There is no predefined method in Excel to convert the Excel data to JSON. You can either use online Excel to JSON conversion software or download an add-in from the Microsoft store for this task to get done.

Why Excel to JSON?

Excel files are heavy weighted files that may contain text, charts, graphs, formatting, functions, and more data.

While the JSON files are light-weighted text-based documents. It stores the data in a simple data structure. Hence, JSON files can be opened on any text software like Notepad or Wordpad.

There are several tools available to convert the Excel data to JSON.

  1. Altova MapForce
  2. White Town XLS to JSON Converter
  3. Oxygen JSON Editor
  4. WTSolution Excel to JSON Converter

Here, we will brief about these tools with their download links.

Tip: WTSolution Excel to JSON Converter is also known as Excel to JSON add-in. Microsoft offers this tool.

For the last tool — Excel to JSON, we will also show you the steps to download and use this software.

Altova MapForce

Altova MapForce is a data mapping and conversion tool as well. It is a useful software to convert various sets of data. Using this tool, you can convert the Excel data to JSON, XML to JSON, and vice versa.

IMAGE

Additionally, this tool also allows the users to convert the JSON to CSV, EDI, Google protocol buffer, and more. This tool is easy to use as it provides a drag and drop interface. It also supports advanced data processing.

Altova MapForce is not free software but comes with 30 days of a free trial. Download the Altova MapForce tool from the following link.

White Town xls to JSON converter

This software is an xls to JSON converter. As the name implies, it allows the users to convert the Excel data into JSON format. However, it only allows the Excel data to be changed into JSON format. This software supports both formats (.xls and .xlsx formats) of Excel.

IMAGE

One of the biggest advantages of using this software, it is free of cost. Although you can also buy the personal or business license of it. It is very easy to use that is why it is very popular, mostly for those who transfer their data online.

You can download the White Town xls to JSON converter tool from the following link.

Oxygen JSON Editor

Oxygen JSON Editor is software used to convert the Excel file data to JSON format by mapping the Excel columns to JSON object key. This software is complex software than the other ones we have described above.

As Oxygen JSON Editor is a complex software, it has complex features too. Complex features, such as — structure validation, indent, format, and content completion. Additionally, this software also allows us to convert the XML document to JSON format.

IMAGE

Oxygen JSON Editor works differently than the other Excel to JSON converters. It uses XSLT stylesheet template for the conversion. Most professionals prefer this software to convert their data. It is a paid software whose personal, business, and academic versions are available on its official website.

Check out its official site to download the Oxygen JSON Editor.

WTSolution Excel to JSON converter

This one is the last Excel to JSON converter of this chapter by using which one can perform Excel to JSON conversion on their data. It is a simple application for this task to perform. This software supports two types of conversions on Excel data: Row and Nested.

You have also listened its name as Excel to JSON add-in. Microsoft offers this add-in named Excel to JSON that helps the users to convert their Excel data into JSON format. Now, let’s know something about Excel to JSON add-in and also see the downloading steps for it.

Excel to JSON add-in

Excel to JSON is an add-in offered by Microsoft to convert the Excel sheet data to JSON format. When the data is converted to the JSON format, Excel sheet columns are changed to object keys in JSON. It costs no charge from the user to download and use it.

You can download this add-in from the Office store.

Requirement

Excel to JSON add-in will work only on Excel 2013 or higher versions. Hence, your Excel version must be 2013 or higher.

Limitation

This add-in has a limitation.

It can convert the selected Excel data to JSON format.

Currently, two types of conversions are supported by this add-in.

  1. Row
  2. Nested

Row conversion

In row type conversion, the first row is treated as header, and rest of the rows are interpreted as data.

Nested conversion

In nested type conversion, you can define a JSON schema. This add-in will do the conversion accordingly, the schema you have provided.

Download add-in

Excel to JSON add-in is available in Office store; you can download it from there. For step by steps learning, follow this chapter below —

Step 1: Download the Excel to JSON add-in from the following link.

Step 2: A webpage of the Office store will open, where click on the Get it now button.

How to convert Excel to JSON?

Step 3: Before start downloading, it will ask you to log in to your Microsoft account with valid credentials.

How to convert Excel to JSON?

If you do not have a Microsoft account, signup for free to create new account.

Step 4: When you login to your Microsoft account. It will ask for some basic information required by this app before download. Here, provide these details and click the Continue button.

How to convert Excel to JSON?

Tip: The fields that are marked with * sign are required fields and others are optional.

Step 5: Now, click the Open in Excel button here.

How to convert Excel to JSON?

If you don’t have any MS Excel 2013 or above version downloaded in your system, you can go for office online. By clicking on this link.

How to convert Excel to JSON?

We have clicked on the Open in Excel.

Step 6: On this popup, leave the checkbox unmarked and click on Open Excel here.

How to convert Excel to JSON?

Step 7: Your Excel will be opened on your system, but it requires an internet connection. If it is not available, you may get this type of warning error.

How to convert Excel to JSON?

Step 8: When you click on OK, it will show you one more panel that shows you some reason why this error can occur. This error can be because of the following reasons.

How to convert Excel to JSON?

So, connect your system with the internet and close the currently opened Excel workbook.

Step 9: Follow Step 5 and step 6 again, where click on the Open the Excel button.

This time your system is connected to the internet. So, it will not show any error and interruption while installing the add-in.

Step 10: An interface on the Excel file will open like this with Excel to JSON add-in. Now, add this add-in to your Excel tab by clicking on Trust this add-in button present on the right panel.

How to convert Excel to JSON?

Step 11: Excel to JSON add-in is successfully added to the Excel ribbon as a tab in the end. See here —

How to convert Excel to JSON?

Step 12: Your Excel to JSON add-in is ready to launch. It is available inside the Excel-to-JSON tab by the name Launch Excel-to-JSON button.

How to convert Excel to JSON?

Note: The Excel file, which is currently opened, is read-only that contains a few instructions about this tool. Hence, open the targeted file first, which you want to convert Excel to JSON.

Step 13: Prepare a new Excel sheet or open that one whose data you want to change in format. We have opened an existing file of person details and click on the Launch Excel-to-JSON button.

How to convert Excel to JSON?

Step 14: Once you click on it, you may get this error. Ignore it and click OK to move forward.

How to convert Excel to JSON?

Tip: While using this add-in to convert your data, your system must be connected to the internet. Otherwise, you may face problems.

Step 15: Now, select at least first two row’s data or all where first one is considered as header and the other as data. Then click on GO in the right panel.

How to convert Excel to JSON?

Step 16: You will see that the selected data is converted into JSON format and available below the Go button.

How to convert Excel to JSON?

Step 17: Copy this data from here, paste this JSON data into a file and save it. Hence, click on the Copy to clipboard button here.

How to convert Excel to JSON?

Step 18: JSON data is successfully copied to the clipboard.

How to convert Excel to JSON?

Step 19: Now, paste this copied clipboard data to a Word file and save it. The copied data will look like as shown below —

How to convert Excel to JSON?

Excel to JSON using VBA code editor

Besides using all these tools, you can use the in-built feature of Excel (VBA code editor) to convert the Excel data to JSON format. Make a code for it and execute the code; it will do the mapping of Excel columns to JSON object keys and convert the data into JSON.

If you are comfortable in doing coding, then it’s a good way for you. Thus, you do not need to explicitly download the above discussed tools to convert your Excel data to JSON format. While you can do it without downloading any software on your system using Excel VBA code Editor.

Tip: Your Excel data must have column names because the first row is always considered as a header.

VBA Code

Following is the complete code for the conversion of the Excel file data to JSON format. Copy this following code and paste this to your respective VBA code editor.

In this VBA code, we have defined a function named ExcelToJSON that will later be used in an Excel file for converting Excel data to JSON format. Let’s see how it will execute.

Syntax

Now, go back to the Excel file and write the following ROUND() formula in an Excel cell where you want to place the converted JSON result. For example,

=ExcelToJSON(A1:F3)

How to convert Excel to JSON?

Currently, we are converting the first two Excel rows data into JSON format only.

Press the Enter key and get the result and see that the data is successfully converted into JSON form. Similarly, you can use this function for more conversion.

How to convert Excel to JSON?

For the detailed description of this code, see our next tutorial, where we have explained this code and variables created and used in it.


Понравилась статья? Поделить с друзьями:
  • Js excel to blob
  • Jquery данные в excel
  • Jquery выгрузка в excel
  • Jquery datatables export excel
  • Jqgrid export to excel