Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Write Your First Query
-
In your CRM Analytics org, create a new dashboard:
- Click Create.
- Click Dashboard.
- In the window Choose a dashboard template, click Blank Dashboard, then click Continue.
- Drag a chart widget to the dashboard canvas.
- In the chart widget, click Chart, then select DTC Opportunity dataset.
-
Click the SAQL Mode button to launch the SAQL editor.

The SAQL editor displays the SAQL query used to fetch the data and render the chart:
11 q = load "DTC_Opportunity_SAMPLE";
22 q = group q by all;
33 q = foreach q generate count() as 'count';
44 q = limit q 2000;Let’s take a look at each line in the query.
| Line Number | Description |
|---|---|
| 1 |
q = load "DTC_Opportunity_SAMPLE"; This loads the dataset that you chose when you created the chart widget. You can use the variable q to access the dataset in the rest of your SAQL statements. |
| 2 |
q = group q by all; In some queries, you want to group by a certain field, for example Account ID. In our case we didn’t specify a grouping when we created the chart. Use group by all when you don’t want to group data. |
| 3 |
q = foreach q generate count() as
'count'; This generates the output for our query. In this simple example, we just count the number of lines in the DTC Opportunity dataset. |
| 4 |
q = limit q 2000 This limits the number of results that are returned to 2000. Limiting the number of results can improve performance. However if you want q to contain more than 2000 results, you can increase this number. |
You can click Back to go back to the chart. You can use the UI to make modifications to the chart, then view the resulting SAQL.