# Calculated Element

Contents[Hide]

The Calculated Element transform lets you create new elements by writing C# expressions. The result of each expression is a new output element.

Related video: Data Cleansing with Data Cubes

## 1. Input

The Calculated Element transform requires input data from at least one transform.

For example, we will use the data cube created in the article Using a data cube to join tables.

To add the transform, select the connection between the second Join and the Process Result.

Click Insert Common from the toolbar and select Calculated Element.

## 3. Configure the transform

Double-click the Calculated Element transform to configure it.

In the Calculated Element dialogue, provide a name and description for the transform, and de-select the columns FirstName and LastName to omit them from the output.

Click the plus icon under Calculated Elements to add a calculated element to the transform.

Note
You can add multiple elements using a single transform.

On the Calculated Element new element dialog, provide a name and description for the new element, and select String in the Data Type drop-down.

Enter the following C# code in the expression field:

`return \$FirstName\$ + " " + \$LastName\$;`

Note
Expand the Automatic Placeholders section to view a list of available placeholders.

Click Submit and close the Calculated Element dialogue.

## 4. Output

Select the Process Result transform and expand the Data Preview panel. The column Full Name has been added to the output.

## 5. Expression samples

The following are some common expressions for calculated elements:

• Get year part from a date column:

```DateTime date1 = \$ModifiedDate\$;
return date1.Year;```
• Add 3 months to a date column:

```DateTime date1 = \$StartDate\$;
• Check the Year and return a string:

```DateTime date1 = \$Date\$;
int i =  date1.Year;string s = "";
if (i == 2015)
{
s = "This Year";
}
else
{
s = "Other Year";
};
return s;
```
• Get the lowercase equivalent of a string:

```string s = \$FirstName\$;
return s.ToLower();
```
• Change a UNIX timestamp to date format:

```DateTime dtDateTime = new DateTime(1970,1,1,0,0,0,0,DateTimeKind.Utc);
return dtDateTime;
```

## 6. Notes

• The JavaScript statement switch is not supported.
• When using the Decimal data type, two additional optional fields become available:
1. Precision - Maximum count of digits in the whole number.
2. Scale - Maximum count of decimal digits.