---
schema_version: "1"
id: 01009049f8372aaab5c7244b48dee09e7be9a9b145da50ca2b3a802b47a7fbc4
title: Append Datasets using union
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-examples-union.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-examples-union.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 441618c3d6c5ec80d70a62a945ebdc2297428a25dd4e815969adbc2ac862ed7f
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# Append Datasets using union

You can append data from two or more data streams into a single data stream using `union`. The data streams must have the same field names and structure.

To use `union`, first load the dataset and then use `foreach` to do the projection. Repeat the process with another dataset. If the two resulting data streams have an identical structure, you can append them using `union`.

Let’s say that you have two opportunity datasets from different regions that you brought together using the Salesforce mulit-org connector. You want to add these datasets together to look at your pipeline as a whole.

The OppsRegion1 data stream contains these fields.

![Diagram showing the first dataset.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_union_ds1.png)

The OppsRegion2 data stream contains these fields.

![Diagram showing the second dataset.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_union_ds2.png)

Use `union` to combine the two data streams.

```nolang
ops1 = load "OppsRegion1";

ops1 = foreach ops1 generate 'Account_Owner', 'Account_Type', 'Amount';

ops2 = load  "OppsRegion2";
ops2 = foreach ops2 generate 'Account_Owner', 'Account_Type', 'Amount';

-- ops1 and ops2 have the same structure, so we can use union
opps_total = union ops1, ops2;

```

The resulting data stream contains both sets of data.

![Diagram showing the combined datasets.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_union_bothds.png)

**See Also**

- [union](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/reference/bi-saql-statement-union.md)
