# Constant Value Transformation

## Overview

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

### Video

{% embed url="<https://www.youtube.com/watch?t=49s&v=po_-ibormDw>" %}

## 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/astera-data-stack-v10/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/astera-data-stack-v10/dataflows/destinations/database-table-destination).
3. Map the *Employees* dataset from the source object to the destination table, *Employees\_Database*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fj1353MyHeEqWVQODKpNK%2Fgif-mappping.gif?alt=media\&token=b952c8df-402b-4d0c-b7a0-b3e6b7a99054)

{% 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FM6uIQembQNKUK3mIZIhl%2Fgif-drag-and-drop-1.1.gif?alt=media\&token=e54b595f-f510-48b6-aaf4-b1b9671f6735)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FPMZk7ib6m5xVSGpROUs0%2Fgif-properties-1.2.gif?alt=media\&token=0bdbb528-2b0b-4636-b187-35b380ee65dc)

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.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FtSaIef7jwZMmXHFhEaym%2F5.png?alt=media\&token=88b24272-b61f-4533-9b8f-6b168810c843)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FA6FX7xFdciXnRl656JrO%2FUntitled.png?alt=media\&token=e57cab54-2695-44d8-8912-f50265724c8a)

*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.

Your transformation object will now look like this:

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F54gvndzcmZWKDAcBk31M%2F7.png?alt=media\&token=aa125bd1-fbe5-4852-b1c8-0243546a6ecd)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FaEkhUigZxSmmaFrHM96x%2F8.png?alt=media\&token=3faa0745-5245-4e2a-b1c8-ca2607729b50)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F4f3UK1rrIB4GQT73in1C%2Fgif-preview-output-1.3.gif?alt=media\&token=f5e7811e-8450-4a25-8aed-711b219c7b35)

Your final output will look like this:

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F5K8IXERL3MCiODDx6kvE%2F9.png?alt=media\&token=ed6f2c19-5319-4b1e-a260-040f186feb6c)

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.
