Order Interactions

Use the asOrder() serialization function to specify the sort order in a SAQL query.

Let’s look at an example where the selection in a toggle widget determines the sort order in a SAQL query.

Given this data from a source query:

1[
2    {order: "first", direction: "desc"}
3    {order: "second", direction: "asc"}
4]

To order by a single field, apply this order logic. When you don’t specify the direction in the query, the default is ascending.

1q = order q by {{cell(stepFoo.selection, 1, "order").asOrder()}};

After CRM Analytics evaluates the interaction, the grouping becomes:

1q = order q by 'second';

To order by multiple fields, use this grouping logic.

1q = order q by {{column(stepFoo.selection, ["order"]).asOrder()}};

After CRM Analytics evaluates the interaction, the grouping becomes:

1q = order q by ('first', 'second');

To specify the order and the direction, use this grouping logic.

1q = order q by {{row(stepFoo.selection, [], ["order", "direction"]).asOrder()}};

After CRM Analytics evaluates the interaction, the grouping becomes:

1q = order q by ('first' desc, 'second' asc);