[SalesForce] Marketing Cloud – Can I pull in data from a data extension other than the one I’m sending to

I have two data extensions.

Data extension A has a record for each quote created via our website in the last 24 hours. There may be multiple records per email address, if the user has elected to create multiple quotes.

Data extension B is created from data extension A, and captures unique email addresses from the last 24 hours. There is one record per email address.

I would like to send one follow-up email to the user, which includes a table containing information about all of the quotes they created in the last 24 hours. Obviously I cannot just send to data extension A, because that would send them an email for each quote record. My plan to accomplish this was creating data extension B and sending to that data extension. However, I've realized that I don't know how to code the email to reference data extension A while sending to data extension B.

Any advice for how to accomplish this task?

Best Answer

To help anyone else that runs across this issue, I am turning the comments into an answer.

You would use the LookupRows() AMPScript function if you need to grab multiple values returned from a different DE

Sample: (multiple results)

%%[
   SET @Rowset = LookupRows('DEa','PrimaryKey', PrimaryKey)

   FOR @i = 1 TO ROWCOUNT(@Rowset) DO
     SET @Row = Row(@Rowset,@i)
     SET @fName = Field(@Row, 'FirstName')
     SET @lName = Field(@Row, 'LastName')

     OUTPUT(CONCAT(@fName, " ", @lName, "<br />")
     /* This will gather the First and Last Name of each row and Output it */

   NEXT @i
]%%

Sample: [single result using LookupOrderedRows()]

%%[
   SET @Rowset = LookupOrderedRows('DEa', 1, 'EmailAddress ASC','EmailAddress', emailaddr) 

   /* Returns only a single row meeting the WHERE criteria of EmailAddress = emailaddr 
   and ordered by Email Address Ascending */

     SET @Row = Row(@Rowset,1)
     SET @fName = Field(@Row, 'FirstName')
     SET @lName = Field(@Row, 'LastName')
     SET @otherValue = Field(@Row, 'OtherValue')

     /* Set the fields you want from the 'Row' (@Row) using the Field() function */

]%%

Or you would use the Lookup() AMPScript function if you only need a single value returned from a different DE.

Sample

SET @fName = Lookup(DE_A, 'FirstName', 'email_address', emailaddr) /* Will return the First Name only from a single entry*/

Related Topic