Data Selection Functions

A data selection function selects data from a source. The source can be either a selection or results of a query. The function returns a table of data, where each column has a name, and each row has an index, starting with 0. From the table, you can select one or more rows, one or more columns, or a cell to include in your interaction.

In cases where multiple rows or columns of data are selected, the function returns a two-dimensional array. When a single row or single column is selected, the function returns a one-dimensional array. When a cell is selected, the function returns a scalar value. The function returns null if the source is empty. If the function tries to select data that doesn’t exist, an interaction error occurs. For example, the table only has two rows, but you try to select data from the third row.

Returns a single cell of data as a scalar, like "This salesperson rocks", 2, or null. An error occurs if the rowIndex isn’t an integer, the columnName isn’t a string, or the cell doesn’t exist in the table.

ArgumentDescription
source(Required) Specify the name of the query and selection or result.
rowIndex(Required) Specify the row using its index. Row index starts at 0.
columnName(Required) Specify the column name.

This example is based on the myStep source query. Assume that myStep.selection retrieves these rows from the query.

Although CRM Analytics doesn’t store this data as a table, let’s show the data in this format to make it easier to understand the example.

(row index)stateNameAmount
0CA100
1TX200
2OR300
3AL400

Function:

Output:

Returns one column of data as a one-dimensional array or multiple columns of data as a two-dimensional array.

ArgumentDescription
source(Required) Specify the name of the query and selection or result.
columnNames(Required) Specify an array of column names. The order of the listed columns affects the order that the columns appear in the output. The order is important for serialization functions. For example, the asOrder function requires the first element to be a field name and the second to be the direction.

These examples are based on the myStep source query. Assume that myQuery.selection retrieves these rows from the query.

Although CRM Analytics doesn’t store this data as a table, let’s show the data in this format to make it easier to understand the examples that follow.

(row index)stateNameAmount
0CA100
1TX200
2OR300
3AL400

Function:

Output:


Function:

Output:

Returns one row of data as a one-dimensional array or multiple rows as a two-dimensional array. For selection interactions, you typically use this function to return the first row or all rows. For results interactions, you might want specific rows. To determine the row index, display the query results in a values table.

ArgumentDescription
source(Required) Specify the name of the query and selection or result.
rowIndices(Required) Specify an array of row indices, where each element of the array identifies a row. Row index 0 identifies the first row. To include all rows, specify an empty array.
columnNames(Optional) Specify an array of column names to select and order them. If not specified, all columns are selected and every row has the same order of columns. However, that order isn't guaranteed to be the same across different queries.

These examples are based on the myStep source query. Assume that myStep.selection retrieves these rows from the query.

Although CRM Analytics doesn’t store this data as a table, let’s show the data in this format to make it easier to understand the examples that follow.

(row index)stateNameAmount
0CA100
1TX200
2OR300
3AL400

Function:

Output:


Function:

Output:


Function:

Output:


Function:

Output: