Excel Spreadsheet Automation with the QUERY Formula



Pull data, automate spreadsheets, and more with the QUERY formula.

The CData Excel Add-In for Azure Data Lake Storage provides formulas that can query Azure Data Lake Storage data. The following three steps show how you can automate the following task: Search Azure Data Lake Storage data for a user-specified value and then organize the results into an Excel spreadsheet.

The syntax of the CDATAQUERY formula is the following: =CDATAQUERY(Query, [Connection], [Parameters], [ResultLocation]);

This formula requires three inputs:

  • Query: The declaration of the Azure Data Lake Storage data records you want to retrieve, written in standard SQL.
  • Connection: Either the connection name, such as ADLSConnection1, or a connection string. The connection string consists of the required properties for connecting to Azure Data Lake Storage data, separated by semicolons.

    Authenticating to a Gen 1 DataLakeStore Account

    Gen 1 uses OAuth 2.0 in Azure AD for authentication.

    For this, an Active Directory web application is required. You can create one as follows:

    1. Sign in to your Azure Account through the .
    2. Select "Azure Active Directory".
    3. Select "App registrations".
    4. Select "New application registration".
    5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
    6. Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
    7. Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.

    To authenticate against a Gen 1 DataLakeStore account, the following properties are required:

    • Schema: Set this to ADLSGen1.
    • Account: Set this to the name of the account.
    • OAuthClientId: Set this to the application Id of the app you created.
    • OAuthClientSecret: Set this to the key generated for the app you created.
    • TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
    • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

    Authenticating to a Gen 2 DataLakeStore Account

    To authenticate against a Gen 2 DataLakeStore account, the following properties are required:

    • Schema: Set this to ADLSGen2.
    • Account: Set this to the name of the account.
    • FileSystem: Set this to the file system which will be used for this account.
    • AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
    • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
  • ResultLocation: The cell that the output of results should start from.

Pass Spreadsheet Cells as Inputs to the Query

The procedure below results in a spreadsheet that organizes all the formula inputs in the first column.

  1. Define cells for the formula inputs. In addition to the connection inputs, add another input to define a criterion for a filter to be used to search Azure Data Lake Storage data, such as Type.
  2. In another cell, write the formula, referencing the cell values from the user input cells defined above. Single quotes are used to enclose values such as addresses that may contain spaces.
  3. =CDATAQUERY("SELECT * FROM Resources WHERE Type = '"&B5&"'","Schema="&B1&";Account="&B2&";FileSystem="&B3&";AccessKey="&B4&";Provider=ADLS",B6)
  4. Change the filter to change the data.

Ready to get started?

Download a free trial of the Excel Add-In for Azure Data Lake Storage to get started:

 Download Now

Learn more:

Azure Data Lake Storage Icon Excel Add-In for Azure Data Lake Storage

The Azure Data Lake Storage Excel Add-In is a powerful tool that allows you to connect with live Azure Data Lake Storage data, directly from Microsoft Excel.

Use Excel to read, write, and update Azure Data Lake Storage data. Perfect for mass imports / exports / updates, data cleansing & de-duplication, Excel based data analysis, and more!