Newer Version Available
Formatting the Results of a Query with Multiple Datasets
When a query has multiple datasets, the query results are formatted using the XMD of the
first loaded dataset.
For example, the Quota dataset is loaded first so its XMD is used to format the projected columns Amount and Percent Attained.
1-- The Quota dataset's XMD is used because it is loaded first
2quota = load "Quota";
3ops = load "Opportunity";
4q = cogroup ops by 'Owner.Name', quota by 'Employee';
5q = foreach q generate quota.'Employee' as 'Account Owner', sum(ops.'Amount') as 'Amount', trunc(sum(ops.'Amount')/sum(quota.'Quota')*100,2) as 'Percent Attained';However, the Quota dataset’s XMD doesn't contain the Amount field, so the projected amount is formatted as a number rather than as currency.

The Opportunity dataset’s XMD contains an Amount field that is formatted as currency. To format the amount as currency, load the Opportunity dataset first.
