Advertisement
Filtering & Grouping
Write SAQL filter conditions and group-by clauses, including multi-level grouping for drill-down charts.
Filtering & Grouping
Filter operators
q = filter q by 'Amount' > 10000;
q = filter q by 'StageName' in ["Closed Won", "Closed Lost"];
q = filter q by 'CloseDate' in ["2026-01-01".."2026-03-31"];
Combine conditions with && (and) and || (or), and negate with !.
Grouping
q = group q by ('Region', 'StageName');
Grouping by multiple fields, as above, is what powers drill-down charts — each field becomes a level a viewer can click into.
Grouping by date
q = group q by 'CloseDate_Year';
Date fields in CRM Analytics datasets are automatically exploded into derived fields (_Year, _Quarter, _Month, _Day) at dataset creation time — group by whichever grain the chart needs.
What you'll learn next
Next: the aggregate and string functions available inside foreach ... generate.
Advertisement
SAQL Basics
Learn SAQL — the Salesforce Analytics Query Language — and how every chart in CRM Analytics is really a query underneath.
Functions & Aggregates
The aggregate, string, and date functions you'll reach for most often when writing foreach ... generate clauses.
Advertisement
Advertisement