Skip to main content

Creating Mapping Rules

Table of Contents


Mapping Rules

Mapping tells Verodat which columns from your uploaded data correspond to the required fields in your dataset. Here's how it works:

  1. Defining Columns:

    • A mapping enables you to define the columns to upload from your original file, and map them to the required fields in a Verodat dataset.

  2. Transformation:

    • Verodat enables you to create expressions and formulas to transform the structure of data at the mapping stage.

      • For example, you can use the SPLIT function to take information from one column and spread it into different columns.

  3. Save multiple mappings

    • Verodat enables you to save multiple different mappings related to different suppliers, or sources of data in your data supply chain for use in the future.

      • These saved mappings enable Verodat to automate data ingestion.

      • You can share these saved mappings with Supplier Groups.


Map data from source to target

Step 1: Associate Columns with Required Fields

This step creates an association between the columns in the file you have uploaded, and the ‘target fields’ required in Verodat.

  • On the left side, you have the "target fields" in Verodat (this is the requirements - what's needed in that data feed).

  • On the right side, in the red square, you see the names of columns from your uploaded file (this is your source data).

  • To create a mapping, you drag a piece of your source data (from the right, red square) and drop it next to the target field (in the green square).

    • You can also type the name of your source field in curly brackets (like {Name}) in the target field expression box.

  • If it works, you'll see a sample of your data to confirm it's the right match (shown in the black box below).

Important Stuff:

  • Every field marked as mandatory needs to have a map.

  • Don't forget to save your progress! Click "Save" and give a name to your new mapping.


Step 2: Apply formulas or expressions to transform data

This step enables you to make further adjustments to the data in your uploaded file to match the required fields.

To create a transformation rule, click on those edit icon next to the target fields to add a transformation expression to a field. A pop-up titled "Expression Builder" will appear.

This will open the code editor where you can add your function. Functions are much like an Excel Formula

  • On the right side tabs, you'll find your Source Fields (remember, these are parts of your uploaded data). There's also a handy list of ready-to-use formulas (Functions) for simple data changes. Think of these like shortcuts for quick transformations.

  • To use a function, drag and drop a function from the list, and add any source fields that you want to include into the code area on the left. There's a guide to commonly used functions below.


Commonly used mapping functions

Creating a manual entry

Verodat enables you to manually enter data against a mapping target field. This will populate every row of your uploaded file with your manually entered data. You can manually enter a date, text, or a number.


Text

To enter text against a specific column in your dataset, you must surround it with "quotation marks". For instance, if you are required to classify each expense by department and that field does not come in the file to be uploaded. In these cases, you could directly pass a text value (in quotes) to the expression, so every row uploaded by the marketing department will be categorized as "Marketing".


Number

Let's say you need the department and the Cost Centre code. You could pass a number directly to the Cost Centre target field, and these could defer for each mapping. A number does not require quotation marks, so it can just be entered as 10.


Date

If you also want to include a manual date entry against your mapping, there are a few options. To enter one specific date, you should follow the format YYYY-MM-DDT00:00:00Z. This will enter the date you added across all rows in the submission.

YYYY-MM-DDT00:00:00Z

Another option is to add in today's date, which you can do using the 'TODAY' function. By adding the function TODAY()toEpochMilli() we return the date of processing. This value will be inserted for every row in the file being uploaded

TODAY()toEpochMilli()


Shortcuts

Below are some shortcuts you can use to concatenate data, or perform basic mathematics.

Text

  • &

    • To add two fields together

  • & " " &

    • to add two fields together with a space

  • & "," &

    • to add two fields together with a comma

Numbers

  • + -

    • to add two numeric fields together

  • - -

    • To subtract two numeric fields from each other

  • /

    • to divide two numeric fields

  • *

    • to multiply two numeric fields


Example Rules

Here's a sample dataset that we'll be using as an example in the below rules:

Full Name

Date

Reference Code

Address Line 1

Address Line 2

Postcode

Order Quantity

Price

Total Sales

Category

Product

John Smith

21/11/2022

" AS32 1234Z "

N5, Road Avenue

Coventry, West Midlands, UK

CV1 3DK

536

17

6801

"Food"

"Cereals"

Trim

To remove extra spaces, or retrieve part of a cell value, use the TRIM, LEFT or RIGHT formula.

TRIM({Reference Code})


Lookup

If you'd like to pull a value in your existing data, you can use a LOOKUP function. This function looks for a value in a column that is in an external dataset and retrieves the value specified in the required target field. For example, in our example data above, this rule matches the category from another dataset called "Tax Rate History", to the value in the Category field to improve consistency across the system.

The format for this rule is as follows: (Dataset Name (Text), column_to_match (lowercase, underscore instead of spaces), Value to Look For (Any)"

LOOKUP_EXISTS("Tax Rate History", "tax_category", {Category})

We can also use a lookup to return a value. For example, while developing mapping rules in a dataset like the one shown above, we can retrieve values from other datasets (e.g., "Tax Rate History") to complement our data and improve consistency across the system.

The format for this rule is as follows: (Dataset Name (Text), column_to_match (lowercase, underscore instead of spaces), column_to_retrieve (lowercase, underscore instead of spaces), Value to Look For (Any)"

LOOKUP_GET("Tax Rate History", "tax_category", "rate", {Category})


DATEVALUE

This function is an easy and clean way of transforming date values that are text, into dates that can be stored in date fields in the system.

DATEVALUE({textDate}, "dd/MM/yyyy")


IF

The IF condition enables you to add conditionality to your rules. It can be used to make fields mandatory in certain conditions or fill in blanks with a default value where data is not found, without overwriting existing values in your file. It can also be used to write data to a field based on the value in another column.

It is possible to nest IF() expressions, to create more complex rules with more than 1 or 2 variables to consider. E.g., IF(true, IF(1==2, true, false), false).

The below example creates an additional status in a new column to determine if the order is above a goal amount. If the price multiplied by the quantity is equal to or over 5000, then the status is 'Goal Achieved'. If it is not, the goal is 'Not Achieved'.

IF({price} * {Quantity} >= 5000, "Goal Achieved", "Not Achieved")

Another example is to replace " "(Space) with ""(blank) to remove unnecessary space:

IF({Postal Code}==" ","",{Postal Code})


CONCATENATE

You can concatenate multiple fields of data using Concatenate, or +.

Concatenate works with only text values, whereas + can also operate as an addition sign to perform mathematical equations, or combine numeric values with text.

CONCATENATE({Address Line 1}, ", ", {Address Line 2}, ", ", {Postcode})

{Quantity} + {Product} + " has been sold this month"


SPLIT

You can use split to segment text values by a common divider. For example, values that are separated by a / or a space can be split easily using this formula.

To make use of those values you will need to indicate which value from the list you need to use. In our example case below, we are splitting each section of the value in 'Address Line 2', and we are using commas as the logical separator.

We want to return only city, so we are appending [0] to indicate that we want the first value in the list (starting counting from 0). If you need the second value you will need to indicate [1]. You could also apply this logic in reverse to get the last few values (e.g., {Address Line 2}[-1] will retrieve "UK".

{Address Line 2}.split(", ")[0]


Retrieve a value from the file name, or tab name

In many cases, the file name has relevant information that is worth storing in a target field.

One example could be the date on which the file was processed (e.g., "July 2023"). Combining this expression with .split(), and other functions can help to have a clean output value.

For example, if the file name is "July 2023.xlsx" we can get "July" by using the formula below. This formula is first splitting the components of the file name using a space " " to separate out each value. It is then selecting the first value by appending [0].

metadata.filename.split(" ")[0]

We can also retrieve the year using the following formula. This also splits using blank spaces, getting the second value "2023.xlsx", and follows up by splitting the result using ".xl" which returns the value "2023".

metadata.filename.split(" ")[1].split(".xl")[0]

Similar to the above many Excel users store relevant data in the Excel tabs, which could be a category, a date, a product, etc. It is possible to retrieve this value using similar logic, but replacing metadata.filename, with metadata.workSheet.

metadata.workSheet.split(" ")[0]


MATHEMATICAL: Addition, Subtraction, Multiply, Divide

It is possible to add many fields together and apply mathematical equations to them like addition, subtraction, and multiplication. Simply use + for addition, - for subtraction, / for divide and * for multiplication.

You can also combine any default numbers within these sums, for example if you wish to transform a decimal to a whole number you can simply multiply by 100.

{Total Sales} - 100

{Price} * {Quantity}

{Total Sales} / {Price}


ALLOWED_VALUE_IN_LIST

The ALLOWED_VALUE_IN_LIST function is used to validate whether a given value exists within a predefined list of allowed values.

ALLOWED_VALUE_IN_LIST requires two parameters:

  1. List of Possible Values: This should be defined as an array (e.g., ["Y", "N", "y", "n"]) containing all the permissible values, separated by commas.

  2. Value to Search: The value you want to check against the list of possible values.

ALLOWED_VALUE_IN_LIST(["Y","N"],{Direct Debit})


Adding Filter Rule

A filter rule enables you to selectively process rows from an uploaded file by defining specific conditions to exclude certain data. For instance, you can configure a rule to process only the rows where the "Customer ID" is not null, effectively ignoring any rows with missing or blank "Customer ID" values. This ensures that only valid or relevant records are considered during processing, optimizing the workflow and preventing errors caused by incomplete data.

To add filter click on "Add Filter Rule":

Add expression as:

{Customer ID}!=null && {Customer ID}!=''


Step 3: Testing your formula

Okay, you've crafted your data magic using formulas. Now, let's make sure it works! Follow these steps:

  1. Click "Parse Expression":

    • If your formula is constructed correctly, you will be presented with a free form area to enter in an example value for the data you wish to transform.

  2. Enter Your Example Value:

    • The area is pre-filled with a sample from your source file. You can keep it or add your own examples.

  3. Test Your Formula:

    • To test the result of the formula on the sample value click "Test Expression". If successful, the returned result will appear at the bottom.


Step 4: Saving, and Re-using a mapping

Any rules you've built at this stage can be saved to a mapping for use again.

Click on the saved mapping and you will see the expression box for each mapped target field being filled with the previously applied settings.

Any changes you make to this mapping will need to be saved as a new mapping, or you can overwrite and update the existing mapping.


Filter Rules

You can also click on the "+Add Filter Rule" button to open the Expression Builder for filtering your data, and add a condition to filter out certain rows.

Did this answer your question?