# Union Transformation

The *Union* Transformation object in Astera is used to combine incoming data from two or more inputs into a single output. Its functionality is similar to a union operator in SQL query. It has multiple input nodes and a single output node. It puts together two sets of data irrespective of the repetition that might occur in the datasets. In order to perform this transformation on two datasets, their cardinality must be same.

{% hint style="info" %}
**Note:** An input node in a union transformation cannot receive data from two different set transformations.
{% endhint %}

### Video

{% embed url="<https://www.youtube.com/watch?t=11s&v=pQd2UQuphgo>" %}

### Use-Case

In this example, we have a customers data from two different departments: Sales and Marketing, stored in two separate [*Excel Workbook Source*](/dataflows/sources/excel-workbook-source.md) files. We want to combine this data into a single dataset using a *Union* Transformation object. To keep track of records coming in from each department, we will also add a new field, *Category*, in the layout of the *Union* Transformation object and pass the value using a *Variables* object.

### How to Work with Union Transformation

1. To work with a *Union* Transformation object, drag-and-drop the *Union* Transformation object from *Toolbox > Transformations > Union* onto the dataflow designer.

![](/files/7JtmYlAK4sRP7ixUJH00)

2. Map the *Customers\_Marketing* data to *Input\_1* and *Customers\_Sales* data to *Input\_2* in the *Union* Transformation object.

![](/files/KqoM9olkdMb8UIKeXmNT)

3. Now, right-click on the *Union* Transformation object’s header and select *Properties*.

![](/files/wr7YuuJnFDjxqxLFxkoj)

4. The first window is the *Layout Builder* window, where you can customize your layout or modify your fields. You can also provide a default value to be used in place of null values.

Add a new field, name it *Category* and specify its Data Type as *String*.

Click *Next*.

![](/files/YvvEQkaHx8aBquP9PU6Z)

5. Next is the *Union Transformation Properties* window where there are two input nodes defined as *Input\_1* and *Input\_2* by default. You can also rename them if you want. You can also define any number of input nodes based on the number of datasets you want to combine using the *Union* Transformation object.

![](/files/lTZaQU5GAENBtFAW84tP)

Click *OK*.

6. Now, map the categories of respective departments from the *Variables* resource object to the *Category* field in the *Union* Transformation object. This is done to identify which department a particular record is coming from.

![](/files/rqjFmtE6RV6jRgcILEPX)

Now, we have successfully configured the *Union* Transformation object.

7. Right-click on the *Union* Transformation object’s header and select *Preview Output*.

<figure><img src="/files/EO2UtMElYL8gJeDTkn8M" alt=""><figcaption></figcaption></figure>

You can see that the *Union* Transformation has successfully combined the two datasets into a single, unified dataset.

![](/files/808E9QaWudLyrpT2gLru)

{% hint style="info" %}
**Note:** A *Union* Transformation will show the combined fields from both sources as a resultant, regardless of whether they are present in one or both datasets. In the final output, the dataset which does not have one or more fields will be assigned a null value in that field.
{% endhint %}

8. You can now further transform your dataset or write it to a destination.

![](/files/2R6ivriU3PpGE2dBVsPX)

This concludes working with the *Union* Transformation object in Astera.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.astera.com/dataflows/transformations/union-transformation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
