---
schema_version: "1"
id: f0ca6ad7481589fd9b0495ceb25c0d93f872ea6e2ff3c9133fb8acc81b2194c0
title: Order Interactions
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_bindings/guides/bi-dashboard-bindings-wave-designer-use-case-order.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-bindings/guide/bi-dashboard-bindings-wave-designer-use-case-order.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 958f66d649509260fa8f0489c6e7d6729f7b7e6d1d49065af33c8ac3be43011c
products:
  - Analytics Interactions
  - analytics
---
# 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:

```json
[
    {order: "first", direction: "desc"}
    {order: "second", direction: "asc"}
]
```

To order by a single field, apply this order logic. When you don’t specify the direction in the query, the default is ascending.

```javascript
q = order q by {{cell(stepFoo.selection, 1, "order").asOrder()}};
```

After CRM Analytics evaluates the interaction, the grouping becomes:

```javascript
q = order q by 'second';
```

To order by multiple fields, use this grouping logic.

```javascript
q = order q by {{column(stepFoo.selection, ["order"]).asOrder()}};
```

After CRM Analytics evaluates the interaction, the grouping becomes:

```javascript
q = order q by ('first', 'second');
```

To specify the order and the direction, use this grouping logic.

```javascript
q = order q by {{row(stepFoo.selection, [], ["order", "direction"]).asOrder()}};
```

After CRM Analytics evaluates the interaction, the grouping becomes:

```javascript
q = order q by ('first' desc, 'second' asc);
```
