SI.XQUERY

Overview

The SI.XQUERY function provides you with the ability to query the Sage Intacct REST API objects, in a similar way to the SI.QUERY function. The SI.QUERY function, however, queries the older XML API under the hood.

Sage has exposed more objects through their new REST API; for instance, WIP periods and WIP projects, tax entries, and information for local asset management are only accessible through the new REST API via SI.XQUERY.

You may use either SI.QUERY or SI.XQUERY, but bear in mind these two APIs and functions are configured and may behave differently, and only SI.XQUERY would expose new objects developed by Sage.

SI.XQUERY may be used in conjunction with the following functions:

You can also use Excel aggregation functions (SUM, COUNT, MIN, MAX, and AVERAGE) with the SI.XQUERY function (starting with version 2025.7).

Starting with version 2026.6, SI.XQUERY supports querying custom fields defined in your Sage Intacct environment. You can use custom fields in the Select and Filter arguments and in the Sort setting, and reference them with or without the nsp:: namespace prefix (as returned by SI.XOBJECTDEFINITION) – both forms return the same data.

Syntax

=SI.XQUERY(
    ConnectionName,
    Object,
    Filter,
    Select,
    IncludeHeader,
    Settings,
    OutputColumn1,
    ...
)

Arguments

Argument

Required/Optional

Description

ConnectionName

Optional

Provide one of the following values:

OR

Omit the argument to return results for all compatible connections with default aggregation settings.

Object

Required

Sage Intacct REST object name. For instance, accounts-payable/adjustment

Please use SI.XEXPANDOBJECTRANGE to explore available objects.

Filter

Optional

SQL-like query based on the fields of the object (including custom fields).

The following operators are supported: <, >, >=, <=, =, in, contains, startswith, endswith, not, and, or, is null, is not null

The not operator cannot be used as a negation for expressions (e.g., not (A and B) is not supported), but you can combine it with predicates from the above (e.g., not contains, not startswith are valid expressions).

Joins are not supported.

Use the SI.XOBJECTDEFINITION function to get the list of the object fields.

You can also use the SI.XQUERYFILTER function to build filters for SI.XQUERY.

Select

Optional

Comma-separated list of columns to be included in the resulting dataset (including custom fields).

Reference a field from a related object using dot (.) syntax (relatedObjectName.fieldName).

Use SI.XOBJECTDEFINITION for a list of available field names.

Supports Sage Intacct aggregation operators: sum, max, min, average, count. See below for examples.

If you omit this argument, all the columns from the object will be returned.

Rows where all selected columns have no value are excluded from the results - see Rows with no value in selected columns.

IncludeHeader

Optional

If TRUE, the column headers will be included in the result set.
Default value: TRUE

Settings

Optional

You can either enter a number (e.g. 200) to set how many rows you want or use a list of settings (key-value pairs) to specify advanced query settings. When you enter a number, only the row limit is set – all other settings keep their default values.

Two-dimensional array:
Pass one or more keys with their values. Each key controls a different setting:

  • Sort: A comma-separated list of columns to sort by. Add :DESC after a column name to sort it in descending order (for example, id:DESC).
    Columns without :DESC are sorted ascending.
    Use the SI.XOBJECTDEFINITION function to get the list of the object fields.
    By default, the result set is sorted by the selected fields in the order they appear.

  • Limit: The maximum number of rows to return. For example, 200.
    By default, the size of the result set is not limited.
    Please use Limit along with Sort to ensure your result set is ordered correctly before slicing.

  • Offset: The number of rows to skip from the beginning. This is useful for paging through extensive results. We recommend sorting by a unique column (for example, id) so the data appears in a predictable order.
    Default value: 0
    Please use Offset along with Sort to ensure your result set is ordered correctly before slicing.

  • CaseInsensitive: If set to FALSE, filters ignore uppercase or lowercase differences in the Filter (for example, “Sales,” “SALES,” or “sales” all match the same data).
    Default value: TRUE

  • ShowPrivate: If set to FALSE, excludes objects of private entities.
    Default value: TRUE

  • RefreshMode: Possible values are smart and full. When set to full, a full refresh is performed regardless of the refresh type globally selected by the user. Default value: smart

Example:

=SI.XQUERY(
    "Sage",
    "accounts-payable/adjustment",
    "description not contains('Sales')",
    "id,adjustmentNumber,referenceNumber,description",
    ,
    HSTACK(
        {"Sort"; "Limit"; "CaseInsensitive"},
        {"id:DESC"; 200; TRUE}
    )
)
  • Sorts rows by id descending.

  • Returns up to 200 rows.

  • Ignores uppercase and lowercase differences in the filter.

You can use the VX.SETTINGS function to construct the array.

OutputColumn1

Optional

The address of the header of the first column (top left corner of the Excel table) of the result set.

If the argument is omitted, the result is returned as an array.

OutputColumn2

Optional

The address of the header of the second column of the result set.

It must be on the same row as OutputColumn1.

...



OutputColumnN

Optional

The address of the header of the Nth column of the result set.

It must be on the same row as OutputColumn1.

Output

The function returns a spill range (if OutputColumns are omitted) or an Excel table (if OutputColumns are specified) with the columns specified in the Select argument or all columns if the Select argument is omitted. 

You can read about Table mirroring to leverage Excel tables produced by query functions more efficiently.

Excel Online

Loading large datasets with the function is not performant in Excel Online due to the limitations of the Excel platform in the browser. If your dataset contains more than approximately 100,000 records, we strongly recommend using a desktop version of Excel 365 for Windows or Mac OS.

Rows with no value in selected columns

Unlike other Velixo query functions, the function excludes rows where none of the selected columns has a value. When no rows remain after the exclusion, the function returns #N/A with the message "The query returned no results".

The exclusion applies only when all selected columns are empty for a record. For example, selecting id,discountCutOffDate from the accounts-receivable/invoice object returns every invoice and leaves discountCutOffDate blank for invoices without discount terms, while selecting discountCutOffDate alone returns only the invoices that have one. Two formulas that query the same object with a different Select argument can therefore return a different number of rows.

The exclusion does not remove rows when the Select argument is omitted or contains an aggregation. In both cases at least one returned column always has a value: system columns such as id when Select is omitted, and the aggregation itself in grouped results. A group whose grouping column is empty is returned with an empty value in that column.

The spilled range sizes to the number of rows remaining after the exclusion.

Examples

=SI.XQUERY(,"accounts-payable/summary",,"id,entity.href,name,status,totalAmount")
image-20260630-131747.png

Result: Returns values from the id, name, status, and totalAmount fields from the accounts-payable/summary REST API object, and the field href from the related entity object.

All posted WIP periods ending in 2025 Q1

Say you want to get all posted WIP periods ending in 2025 Q1. 

First of all, you need to find the object name.

Use the SI.XEXPANDOBJECTRANGE function to find the name of the WIP period object. It is construction-forecasting/wip-period.

If, for some reason, you have doubts regarding what object to use, please refer to the Sage Intacct documentation


Then, you might want to look at the object definition to decide what columns you want to see in the query result. Use the SI.XOBJECTDEFINITION function to get all the information.

image-20250916-074454.png

This is the SI.XOBJECTDEFINITION output for construction-forecasting/wip-period.

fiscalYear, id, and isHistoricalImport are the values you can use in the Select, Filter, and Sort arguments, as well as other values in the ID column.


You may select key, periodName, isHistoricalImport, notes, state, and periodEndDate.

The last two will also be used for filtering. The filter will be the following:

periodEndDate >= '2025-01-01' and periodEndDate <= '2025-03-31' and state = 'posted'


Now, the entire query will look this way:

=SI.XQUERY(
    "Sage",
    "construction-forecasting/wip-period",
    "periodEndDate >= '2025-01-01' and periodEndDate <= '2025-03-31' and state = 'posted'",
    "key, periodName, isHistoricalImport, notes, state, periodEndDate"
)


Finally, you can sort your query to make it prettier:
 HSTACK({"Sort";"Limit"}, {"periodEndDate:DESC";3})


=SI.XQUERY(
    "Sage",
    "construction-forecasting/wip-period",
    "periodEndDate >= '2025-01-01' and periodEndDate <= '2025-03-31' and state = 'posted'",
    "key, periodName, isHistoricalImport, notes, state, periodEndDate",
    ,
    HSTACK({"Sort";"Limit"}, {"periodEndDate:DESC"; 3})
)


Aggregation examples

Aggregate a single field

=SI.XQUERY(
  "Sage", 
  "accounts-payable/summary",
  ,
  "summaryType,SUM(totalAmount)"
)


Description

Displays a sum of totalAmount grouped by summaryType in the object ”accounts-payable/summary” for the connection Sage.

image-20251106-142112.png

Multiple aggregations for a single field

=SI.XQUERY(
  "Sage",
  "accounts-payable/summary",
  ,
  "summaryType,SUM(totalAmount),MAX(totalAmount)"
)


Displays a sum of totalAmount and the highest value for totalAmount grouped by summaryType in the object ”accounts-payable/summary” for the connection Sage.

image-20251106-144703.png

Aggregations for multiple fields

=SI.XQUERY(
  "Sage",
  "accounts-receivable/invoice",
  ,
  "State,SUM(totalBaseAmount),SUM(totalBaseAmountDue)"
)


Displays a sum of both totalBaseAmount and totalBaseAmountDue grouped by State, for the connection Sage.

image-20251106-150600.png

Aggregation with multiple levels of grouping

=SORT(
    SI.XQUERY(
      "Sage",
      "accounts-receivable/invoice",
      ,
      "state,moduleKey,SUM(totalBaseAmountDue)",
      FALSE
    ),
    {1,2,3},
    1
)


Displays a sum of totalBaseAmountDue grouped first by state and then by moduleKey. The Excel SORT function is used to combine the grouped aggregations.

image-20251106-155438.png


You can change the order of the fields being retrieved in order to change how the data is grouped.

=SORT(
    SI.XQUERY(
      "Sage",
      "accounts-receivable/invoice",
      ,
      "moduleKey,state,SUM(totalBaseAmountDue)",
      FALSE
    ),
    {1,2,3},
    1
)


Displays a sum of totalBaseAmountDue grouped first by moduleKey and then by state.

image-20251106-155654.png