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]}
- ColumnName is the exact header from your source file.
- 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.
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.
- StudentID,GuardianFirstName,GuardianLastName,GuardianPhone
- 12345,Maria,Garcia,555-0101
- 12345,Luis,Garcia,555-0102
Your form has two distinct, static sections. It is not a repeater.
- A section labeled "Guardian 1" with fields for first name, last name, and phone.
- 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:
- First Name field Expression: {GuardianFirstName[0]}
- Last Name field Expression: {GuardianLastName[0]}
- Phone field Expression: {GuardianPhone[0]}
In the "Guardian 2" section:
- First Name field Expression: {GuardianFirstName[1]}
- Last Name field Expression: {GuardianLastName[1]}
- Phone field Expression: {GuardianPhone[1]}
4. The Result
When the import runs for student 12345:
The system groups the two rows together.
- The expressions with [0] pull data exclusively from the first row (Maria Garcia).
- The expressions with [1] pull data exclusively from the second row (Luis Garcia).
- Both "Guardian 1" and "Guardian 2" sections on the single form are populated correctly.
Key Rules for Indexed Expressions
- Use for Multi-Row to Static Field Mapping: This is the primary use case. It is not used for populating repeaters.
- The Index is Zero-Based: Always remember that the first row is [0].
- 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.
- 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.
Related Articles
Advanced Mapping: Importing Data into Repeaters
A repeater allows a section of your form to be duplicated, which is perfect for lists of information like emergency contacts. This guide explains how to map data from your import file to the fields inside a repeater. Before you begin, ensure your ...
Introduction to Field Mapping
Once you have an Import Configuration set up, the next critical step is field mapping. This is the process of telling the system exactly which column from your source file should populate which field on your form. This connection is made directly ...
Preparing a CSV or TSV File for Import
A correctly formatted CSV (Comma-Separated Values) or TSV (Tab-Separated Values) file is essential for a successful import. While these are standard formats, your file must adhere to specific rules to ensure data is processed accurately. Basic File ...
Import Error Code Reference
When an import fails, the system will log an error code to help you diagnose the problem. This guide explains what each error code means and provides step-by-step instructions on how to resolve the issue. E0001: Cannot Read File Problem The system ...
Overview of the Import Process
The Import Module is a powerful tool for bringing external data directly into your forms. It streamlines workflows, reduces manual entry, and enhances data accuracy by using structured files like CSV, TSV, XML, or JSON to automatically populate or ...