Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
SFMC AMScript Lookup multiple column values from multiple ordered rows
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i
set @lookupValue = AttributeValue("lookupField") /* value from attribute or DE column in send context */
set @lookupValue = "whee" /* or a literal value */
set @numRowsToReturn = 0 /* 0 means all, max 2000 */
set @rows = LookupOrderedRows("DataExtensionName",@numRowsToReturn,"DEColumn1 desc, DEColumn2 asc","LookupColumn", @lookupValue)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowCount do
var @DEColumn1, @DEColumn2
set @row = row(@rows,@i) /* get row based on counter */
set @DEColumn1 = field(@row,"DEColumn1")
set @DEColumn2 = field(@row,"DEColumn2")
Row %%=v(@i)=%%, DEColumn1 is %%=v(@DEColumn1)=%%, DEColumn2 is %%=v(@DEColumn2)=%%
next @i ]%%
%%[ else ]%%
No rows found
%%[ endif ]%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment