Rows.Lookup

Overview 

Returns columns that match the specified values

Syntax 

Rows.Lookup(1, 2, 3, 4)

Function Properties 

OrdinalTypeDescription
1stringRequiredColumns to search for data
2stringRequiredValues uses in search
3numericnumber of rows to return
4stringOrder of rows to return

Examples 

This sample code returns all rows in birthdayDE with a value of 25 for Age.

1var testDE = DataExtension.Init("testDE");
2var data = testDE.Rows.Lookup(["Age"], [25]);

This sample code returns the same rows in birthdayDE, but it limits the results to two rows and sorts the results by last name.

1var testDE = DataExtension.Init("testDE");
2var data = testDE.Rows.Lookup(["Age"], [25], 2, "LastName");

When initializing data extensions with Lookup() in an email, you must use the name of the data extension. When using the function in landing pages, you can use either the name or the external key of the data extension. Make the name and the external key the same value when creating the data extension to ensure you use the correct value at all times.