Build Data Serialization Interactions

The most common SAQL interactions are data serializations. You can build filter, grouping, and projection interactions. These examples show queries that start with q = filter q by or q = group q by followed by the filter or grouping logic. To make the query dynamic, you replace this static logic with an interaction.

You can execute this full sample SAQL query and these interaction examples in a Trailhead Analytics developer org by using the DTC Opportunity data.

These examples use a static step as the query source for simplicity. Each example illustrates the SAQL without and then with an interaction.

The static step to filter is:

A date range filter in SAQL is:

To get that specific format, use the asDateRange() interaction with the date function and parameters.

The static step to filter is:

The SAQL filter for a measure uses the between option &&:

This type of filter has a minimum and maximum value like the asDateRange() function.

The interaction looks like:

The most commonly used filter is the equality filter where one field or column is equal to a specific value. The static step to filter is:

Here's a SAQL example:

The interaction is:

For nonstatic steps, use binding ranges with minimum and maximum values. To bind multiple cell values, use the row data selection function. Define one or more rows that you want to take data from directly after the binding function. In these examples, the value is [0], which indicates only data from the first row of the query results. To define multiple rows, use a comma-separated list, [0,1,2,3]. To include all the rows of the results, use an empty array, [].

Here's a SAQL example for a date range:

Here's a SAQL example for a numeric range:

To create a group interaction, define the grouping and then project it.

The static step for this example is:

Here’s a SAQL example for a grouping:

To create the grouping interaction, use this statement:

The data selection function is cell and it references the value field from the static step.

The second part of the interaction, the projection, is a little more complex. The projection takes a field from the dataset, in this example it's the grouping, and defines how it’s displayed. This interaction uses the expression and alias values. With two or more values, you must use the row selection function.