Advanced Mapping: Using Indexed Expressions

Advanced Mapping: Using Indexed Expressions

While repeaters handle lists of data that can grow or shrink, sometimes you have a fixed number of related entries to import into separate, static sections of a form. A common example is importing contact information into predefined "Guardian 1" and "Guardian 2" sections.

Indexed Expressions are the tool for this job. They allow you to pull data from a specific row when multiple source file rows are grouped together for a single record.

How Indexed Expressions Work

When your import file contains multiple rows for the same person (identified by the same ID), the system groups these rows. An indexed expression lets you pinpoint a specific row within that group to pull data from.

The syntax is simple: {ColumnName[index]}
  1. ColumnName is the exact header from your source file.
  2. index is the position of the row in the group. The index is zero-based, meaning [0] is the first row, [1] is the second, and so on.
Alert
Important: For indexed expressions to work, your data must be sorted predictably. In your Import Configuration, you can set a Sort Order in the "Data Processing" section to ensure rows appear in the correct sequence (e.g., sort by a "Priority" or "ContactType" column).

A Practical Example: Mapping Multiple Guardians

Let's walk through the common scenario of mapping two guardians from two separate rows onto one form.

1. The Source File (guardians.csv)

The file contains two rows for the same student, 12345.
  1. StudentID,GuardianFirstName,GuardianLastName,GuardianPhone
  2. 12345,Maria,Garcia,555-0101
  3. 12345,Luis,Garcia,555-0102

2. The Form Structure

Your form has two distinct, static sections. It is not a repeater.
  1. A section labeled "Guardian 1" with fields for first name, last name, and phone.
  2. A separate section labeled "Guardian 2" with its own set of fields.

3. The Mapping

You map the fields in each section using a different index.

In the "Guardian 1" section:
  1. First Name field Expression: {GuardianFirstName[0]}
  2. Last Name field Expression: {GuardianLastName[0]}
  3. Phone field Expression: {GuardianPhone[0]}

In the "Guardian 2" section:
  1. First Name field Expression: {GuardianFirstName[1]}
  2. Last Name field Expression: {GuardianLastName[1]}
  3. Phone field Expression: {GuardianPhone[1]}

4. The Result

When the import runs for student 12345:
The system groups the two rows together.
  1. The expressions with [0] pull data exclusively from the first row (Maria Garcia).
  2. The expressions with [1] pull data exclusively from the second row (Luis Garcia).
  3. Both "Guardian 1" and "Guardian 2" sections on the single form are populated correctly.

Key Rules for Indexed Expressions

  1. Use for Multi-Row to Static Field Mapping: This is the primary use case. It is not used for populating repeaters.
  2. The Index is Zero-Based: Always remember that the first row is [0].
  3. Sorting is Crucial: The order of your rows determines which data is pulled by which index. Use the sorting options in your Import Configuration to ensure a predictable order.
  4. Cannot Be Used for Record Matching: The field you designate as the Matching Element for Record Matching cannot use an indexed expression.

Next Steps

You have now covered all the advanced ways to map data into your forms. The next logical step in the import process is to learn about transforming your data.