Query Builder

Overview

The Query Builder feature is an intuitive, step-by-step visual tool for constructing query formulas to extract data from an instance of your ERP.

The resulting queries are translated to an ACU.QUERY formula which returns the contents of a specified object , either as an Excel array or an Excel table.

Layout and usage

To open the Query side panel, select a cell where you want to place the created formula and click the Insert button in the Velixo NX ribbon and select Query (you can also select a different cell once the panel is open).

Query Builder side panel opened from the Velixo ribbon in Excel

You can also use Query Builder to edit existing queries created with the tool. Select the cell containing the query you’d like to edit and click InsertQuery from the Velixo NX Excel menu.

Alternatively, right-click the target cell for your query and choose Query Builder from the Velixo menu.

Velixo right-click context menu with Query Builder option highlighted

You can also choose the connection you want to use if multiple are available. The first active connection on the Connection Manager list will be selected by default. The drop-down field will be inactive if your workbook is only connected to a single connection. This functionality corresponds to the Connection parameter in the ACU.QUERY function.


Next, choose an object from which you want to retrieve data from the list in the pop-up panel. You can also use the search bar to look for available objects.

Click the Filter button to choose to search by UI names, API names or both.

Query Builder object selection list with Filter button visible
Query Builder object search results panel with filtered list


Then, you can insert the query into your workbook using the Insert button or customize your query using the adjustments in the Fields, Filters, and Advanced tabs described below.

Query Builder showing Insert and Customize buttons after object selection


Fields

The Fields tab enables you to include individual fields in the results of your query. This functionality corresponds to the Select parameter in the ACU.QUERY function.

The available fields differ depending on the selected object. All available fields are selected by default. To select individual fields, uncheck the Select all checkbox and check the fields you wish to include from the list in the pop-out panel. The list contains available fields for the selected object as well as related objects.

Query Builder Fields tab showing available fields list for selected object
Query Builder Fields tab with multiple fields checked for inclusion in query


When choosing fields, use the chevron icon to expand the list of related objects and their available fields.

Query Builder field list with chevron icon to expand related object fields

Objects that have more than one clear navigation path to exactly one related object are available at the bottom of the list.

Query Builder field list with related object fields expanded under parent object

You can then drag the selected fields to achieve the desired column order.

Query Builder selected fields panel with drag handles for reordering columns


Filters

The Filters tab lets you create filters for your selected fields, arrange filters into groups, and determine AND/OR relationships between filters and filter groups. This functionality corresponds to the Filter parameter in the ACU.QUERY function. You can use values, cell and array references, as well as named items for filtering.

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/mBcRli_cUtuuXKtdAfUzdZRGYVzGwaAZDg.png


Advanced


This tab contains the following options related to the layout of the query results:

  • Return query result - choose whether the results are returned As a spill range or In an Excel Table. The latter also lets you select the target address for your Excel table

  • Excel table address - select the address where the top left cell of the Excel table will be placed

  • Order query result - choose fields used for sorting the results in ascending (ASC) or descending (DESC) order

  • Show column headers - toggle to include column headers. Returns user-friendly field/property names.

  • Limit - declare the number of records to be displayed

  • Offset - declare the number of records to be skipped, starting with the first record. This is useful for paging with extensive results or skipping a number of top results.

  • Split Column headers - Writes the list of selected columns into the cell you specify and makes the main QUERY formula use that cell instead of inlining the full columns expression. Use this when your selected fields make the query formula very long, or you prefer to keep the columns list in a separate “helper” cell for easier maintenance.

  • Split Filter expression - Writes a filter formula into the cell you specify and makes the main formula use that cell as its Filter argument. Use this when your filter is complex/long, or you want to manage filter logic separately from the main query formula.

Query Builder Advanced tab with output layout options including spill range and table

Examples

Return the first 10 records


  • The GL Batch object is selected

  • All fields for the object are included

Query Builder with GL Batch object selected and all fields included (Acumatica example)



  • The record Limit in the Advanced tab is set to “10”

Query Builder Advanced tab with record Limit set to 10 for GL Batch query



Description:

Returns the first 10 records with all fields for the GL Batch object.

Result:

The query above results in the following ACU.QUERY formula:

=ACU.QUERY("Acumatica","PX.Objects.GL.Batch",,,,{"Limit",10})


ACU.QUERY formula result in Excel spreadsheet for GL Batch object with 10 records



Filter by field value


  • AP Tax Detail is selected as the Object

  • TaxRate, TaxID, RefNbr, LineNbr, and TaxAmt are selected as Fields

Query Builder AP Tax Detail object with TaxRate, TaxID, RefNbr, and other fields selected



  • The results are filtered to include only the records where TaxRate is equal to Purchase

Query Builder filter configured with TaxRate field equal to Purchase value



Description:

Returns records for the selected fields for the object AP Tax Detail, where the TaxRate field is set to 5.


Result:

The query above results in the following ACU.QUERY formula:

=ACU.QUERY("Acumatica","PX.Objects.AP.APTax",ACU.QUERYFILTER("Acumatica","PX.Objects.AP.APTax",,"TaxRate",5),"TaxRate,TaxID,RefNbr,LineNbr,TaxAmt")


ACU.QUERY formula result in Excel for AP Tax Detail filtered by TaxRate equals Purchase



Send output to an Excel table, set result order


  • Cost code is selected as the Object

  • IsActive, CostCodeCD, CostCodeID, CreatedByID, Description, NoteText, and tstamp are selected as Fields.

Query Builder Cost code object with IsActive and other fields selected (Acumatica example)



  • The results are filtered to include only the records where the IsActive object is set to true

Query Builder filter set to IsActive equals true for Cost code object



  • The Return query result setting in the Advanced tab is set to Into an Excel table, with cell A2 selected as the target address

Query Builder Advanced tab with Return query result set to Excel table at cell A2



  • The results are set to be displayed in descending order, based on the values in the LastModifiedDateTime field.

Query Builder sort configured to descending order by LastModifiedDateTime field


Description:

Returns records for the selected fields for the object Cost code, where the IsActive field is set to true. The results are returned as an Excel table in cell A2 with results arranged in descending order based on the values in the field LastModifiedDateTime.

Result:

The query above results in the following ACU.QUERY formula:

=ACU.QUERY("Acumatica","PX.Objects.PM.PMCostCode",ACU.QUERYFILTER("Acumatica","PX.Objects.PM.PMCostCode",,"IsActive","true"),"IsActive,CostCodeCD,CostCodeID,CreatedByID,Description,NoteText,tstamp",,{"Sort","LastModifiedDateTime:DESC"},Sheet3!A2)


ACU.QUERY formula result in Excel for Cost code object with active filter and sort applied