currency

Convert monetary values from one currency to another.

This guide explains how to configure the currency instruction. To learn about another instruction, go back to the Available custom script instructions overview.

Introduction

Use the currency instruction to convert monetary values from one currency to another.

The Currency Conversion standard enrichment enables you to convert data between currencies in a few easy steps, instead of using a custom script. For more information, see Currency Conversion.

Creating a custom script enrichment using the currency instruction

To create and configure a custom script using the currency instruction, follow these steps:

  1. Create a custom script enrichment.

  2. In the Instructions step, select the currency instruction.

  3. To configure the custom script instruction, fill in the required fields below, as well as any optional fields you require:

Field name (required)

Enter the name of the column that contains the currency values to convert.

Date column field name (required)

Enter the name of the column that contains the dates that Adverity will use to determine the exchange rate for the currency conversion.

The date column must meet all of the following criteria:

  • The dates are in ISO 8601 format: YYYY-MM-DD. To convert data into this format, use the convertdates instruction before your currency instruction in this enrichment.

  • The date column must be mapped to the data type Date. For more information on Data Mapping, see Applying Data Mapping to a datastream.

Currency service (required)

Select the currency conversion service to use:

Adverity uses the exchange rate from your chosen exchange rate provider for the specific date to convert between currencies. If the exchange rate is not available for the date or if no date column is specified, Adverity uses the latest available exchange rate.

Source currency (required)

Select the original currency of the values to be converted.

Target currency (required)

Select the currency that you want to convert the values into.

Keep source column(s)

Select this field to keep the columns which contain the currency values to convert. If you select this field, make sure the Replace source column(s) field is not selected.

Replace source column(s)

Select this field to replace the values in the columns which contain the currency values to convert. If you select this field, make sure the Keep source column(s) field is not selected.

Currency field name

Enter the name of the new column in which the converted currency values are populated.

Fail on error

Select this field to stop the enrichment if an error occurs.

Subtable

Enter the name for a subtable that you want to use within this custom script.

A subtable is a temporary table that only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.

If a subtable does not exist for the current custom script, the enrichment is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the enrichment and optionally as the output.

Example

Enrichment configuration

Field Name

Cost

Keep Source Column(s)

Select this field.

Date Column Field Name

Leave this field unselected.

Currency Service

ecb

Source Currency

EUR

Target Currency

GBP

Currency Field Name

Cost (GBP)

Data table before enrichment

Campaign

Campaign Start Date

Cost

media

2021-02-03

6500

ecommerce

2021-02-03

8650

media|social

2021-02-05

7985

Data table after enrichment

Campaign

Campaign Start Date

Cost

Cost (GBP)

media

2021-02-03

6500.00

5408.52

ecommerce

2021-02-03

8650.00

7197.49

media|social

2021-02-05

7985.00

6754.75