# Constant Value Transformation

## **Overview**

*Constant Value* Transformation returns a single, predefined value for all records in a dataset.

## **Use Case**

In this example, we have an Excel worksheet containing *Employees*’ data. The data is being written to a database table. The database table contains an additional field that stores department information.

We want to pass a constant value to the *Department* field. To do this, we will use the Constant Value transformation object in Astera. *Constant Value* transformation will be mapped to the *Department* field to append the name of the department with the final output.

## **How to Work with Constant Value Transformation**

1. Drag and drop an [*Excel Workbook* *Source*](https://documentation.astera.com/v/astera-data-stack-v8/dataflows/sources/excel-workbook-source) from the *Sources* section in the Toolbox.
2. Select a destination object from the *Destinations* section in the Toolbox. This is where the transformed data will be written and stored. We will use a [*Database Table Destination*](https://documentation.astera.com/v/astera-data-stack-v8/dataflows/destinations/database-table-destination).
3. Map the *Employees* dataset from the source object to the destination table, *Employees\_Database*.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2Fu0UeawPwSBRv7nDjWHPI%2F0.gif?alt=media)

{% hint style="info" %}
**Note:** There is an additional field (*Department*) in the destination object, but there is no such field in the incoming dataset. To append the *Department* field to the final output, we will use the *Constant Value* transformation object.
{% endhint %}

4. Now, drag and drop the *Constant Value* transformation object from *Toolbox* > *Transformations* > *Constant* *Value*.

![](https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FMQs887UBtG6TWYLWNbVW%2F1.gif?alt=media)

5. Right-click on the *Constant Value* transformation object and select *Properties*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FOVS1qtrRtCVUsWCVsV08%2FConstant%20Value%20Point%205.gif?alt=media&#x26;token=ddf232b7-22c4-4f6c-8993-b87b5a37af81" alt=""><figcaption></figcaption></figure>

6. The *Constant Value Map Properties* window will now open. Here you will see a *Constant Value* section where you can write any value to be appended to your output dataset.

In this case, the value will be ‘Marketing’, to specify the department of the employees in the source dataset.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FRzwanhuJqaPonipPAI8O%2Fimage.png?alt=media&#x26;token=25b51cb9-0db0-4443-b48b-246560ec4148" alt=""><figcaption></figcaption></figure>

7. Click *Next*. A *General Options* window will now open. Click *OK*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FTJCaoh81g3UzyjhNQddS%2Fimage.png?alt=media&#x26;token=b0ec9f2c-66aa-4bde-bc2c-dfd06ccba0f4" alt=""><figcaption></figcaption></figure>

* *General Options* Window: This window shares options common to most objects in the dataflow.
* *Clear Incoming Record Messages:* When this option is checked, any messages coming in from objects preceding the current object will be cleared. This is useful when you need to capture record messages in the log generated by the current object and filter out any record messages generated earlier in the dataflow.
* *Do Not Process Records with Errors:* When this option is checked, records with errors will not be output by the object. When this option is off, records with errors will be output by the object, and a record message will be attached to the record. This record message can then be fed into downstream objects in the dataflow, for example, a destination file that will capture record messages or a log that will capture messages and collect statistics as well.
* The *Comments* input allows you to enter comments associated with this object.

Your transformation object will now look like this:

8. Now map the *Value* field from the *Constant Value* object to the *Department* field in the *Employees\_Database* destination object.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FMXE1dqtZrP07mvsc4q2G%2Fimage.png?alt=media&#x26;token=961319e4-d939-4e08-a645-6be3a739bccd" alt=""><figcaption></figcaption></figure>

9. Right-click on the *Employees\_Database* destination object and click *Preview Output*.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FHQPPdFEmSqsImYOgAw3q%2FConstant%20Value%20Point%209.gif?alt=media&#x26;token=15471cac-5abf-4a72-a5af-c1c1cdd869a0" alt=""><figcaption></figcaption></figure>

Your final output will look like this:

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FtXrvsKqcO1VpjKAVj130%2Fimage.png?alt=media&#x26;token=f12f24b5-fcd0-41a5-a7aa-796a8e1eb7ae" alt=""><figcaption></figcaption></figure>

The *Department* field from our source dataset has been successfully appended with specified records in the final output, through the use of a *Constant Value* transformation object.
