currency
Convert monetary values from one currency to another.
Introduction
Use the currency enrichment instruction to convert monetary values from one currency to another.
To convert between currencies with a more user-friendly interface, use the Currency Conversion enrichment. For more information, see Currency Conversion.
Adverity uses the exchange rate from the European Central Bank 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.
Creating the enrichment
For more information on creating an enrichment, see Using custom scripts.
Configuring the enrichment
To configure the enrichment, fill in the following fields. Required fields are marked with an asterisk (*).
-
Field Name
-
Enter the name of the column that contains the currency values to convert. Leave this field blank to allow Adverity to automatically detect the column which contains the currency values.
-
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.
-
Date Column Field Name
-
Enter the name of the column that contains the dates that Adverity uses to determine the exchange rate for the currency conversion.
Ensure the date column meets all of the following criteria:
-
The dates in this field use the ISO 8601 format
YYYY-MM-DD
. To convert the date format, use the convertdates or convertx custom scripts. -
The date column is mapped to the data type
Date
. For more information on Data Mapping, see Harmonizing data.
If you leave this field empty, Adverity automatically detects the date column. In this case, the date column still needs to meet the above criteria.
-
-
Currency Service
-
Select the currency conversion service to use. Choose either Open Exchange Rates or European Central Bank.
-
For the list of currencies supported by Open Exchange Rates, see the Open Exchange Rates documentation.
-
For the list of currencies supported by the European Central Bank, see the European Central Bank documentation.
-
-
Source Currency
-
Select the currency of the values to be converted.
-
Target Currency
-
Select the new currency for the values.
-
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 contain the enriched data. The enrichment is applied to the whole data extract, then the enriched data is output into the subtable you have named here.
This subtable is a temporary table, which means it 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.
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 before 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 |