I have a two column data extension DE with EMAIL and SENT. I need to output data on an email.


Email = This is not an email address, it is the name of an email template.

Sent = The total of email sent for this Email.

I tried using this code:

SET @p11 = LookupRowsCS("OFFERS","Email","EML_OFFERS_ONE")

then to output the value i used Field(Row(@p11,1),"Sent")

My existing solution is not dynamic, can anyone suggest a better way of doing this?

I just need to be able to output %%=V(@email)=%% %%=V(@sent)=%% in a loop.


Here's an example from my blog: AMPScript Lookup Examples

The third one down is closest to what you're describing.

var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i

set @lookupValue = "whee"
set @numRowsToReturn = 0 /* 0 means all */
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 loop 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 ]%%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.