Newer Version Available

This content describes an older version of this product. View Latest

Group By Date

You can group the result of your SAQL query by DateTime and DateOnly fields.
1q = group q by 'CloseDate';

CloseDate can be DateTime or DateOnly. You can also group by date parts. For example, you can group orders by year and then month.

1q = group q by year('OrderDate'), month('OrderDate');

You can use the DateTime or DateOnly field to cogroup two datasets. For example, you can group two datasets by year.

1a = load dataset1;
2b = load dataset2;
3c = group a by year('CloseDate'), b by year('CloseDate');
4e = foreach c generate year(a.'CloseDate') as 'CloseDate A', year(b.'CloseDate') as
5'Close Date B', sum(a.Amount) as 'Sum of Amount';