---
schema_version: "1"
id: 72c2b3296de4740850fc456a5eade546da4452a5f03e7a6cc06ab9908b7e2ba9
title: Format the Results of a Query with Multiple Datasets
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_xmd/guides/concept/bi-dashboards-steps-multidataset-xmd.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-xmd/guide/bi-dashboards-steps-multidataset-xmd.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3ff2b260eb03c6f2b688fa0240095ef0c9535bfcdd28520853fa34ca5ff2b50e
products:
  - Analytics Extended Metadata (XMD) Developer Guide
  - analytics
---

# Format 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.

```nolang
-- The Quota dataset's XMD is used because it is loaded first
quota = load "Quota";
ops = load "Opportunity";
q = cogroup ops by 'Owner.Name', quota by 'Employee';
q = 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.

![table without formatting](https://developer.salesforce.com/media/bi_dev_guide_xmd/bi_dashboard_steps_multidataset_noxml.png)

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.

![table with formatting](https://developer.salesforce.com/media/bi_dev_guide_xmd/bi_dashboard_steps_multidataset_xmlapplied.png)
