Right now I have this AMPScript which displays the First Name of the email recipient.

var @fname
set @fname = [FirstName]

%%[ var @fname set @fname = [FirstName] ]%% Dear %%[IF not empty(@fname) THEN]%%%%=v(@fname)=%%%%[ELSE]%%Member%%[ENDIF]%%

Since my data extension includes a primary key which is not email address. One email can be in multiple rows with a different name. How can I make sure ampscript does not pickup an older record where name is different but recipient email is same? In my case, I want ampscript to display first name from the record where @EmailSend_Status == false. How can I do that?


You can do this using the LookupRows- or Lookup-function and using the email address and the sendstatus as where condition parameters. The lookup function works if you only want to retrieve the value of one column. If you need to use data from multiple columns, you need to use LookupRows

LookupRows example:

    Var @Row
    Set @Row = LookupRows("YourDataExtensionName", "EmailAddress", @VariableContainingEmailAddress, "EmailSend_Status", "True")

Lookup example:

    Var @fname
    Set @fname = LookupRows("YourDataExtensionName", "FirstName", "EmailAddress", @VariableContainingEmailAddress, "EmailSend_Status", "True")


| improve this answer | |

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.