I would like to add personalization to an email from a secondary DE.

First of all, we have 2 DEs involved:

  • The first is the one that we are targeting customers and has 2 Primary Keys.
  • The second DE has 1 Primary Key from which we want to take the personalization field.

We have tried to achieve this with the Lookup function but with only one Primary Key (of the 1st DE) and a personalization error occurred.

Ιs there a way to add to the Lookup function both keys (if this will resolve the issue) or we should follow another way in order to achieve this?

  • Hello, please add more information of what you have done, e.g. how your Lookup function looks like and what error text did you get? and why do you have any issue adding more conditions to the Lookup function? So that we would be able to answer your question accurately.
    – Niko
    Commented Sep 17, 2021 at 8:44
  • Hello, our case is that the relationship between those 2 tables is 1/n. This mean that there are some cases were the lookup function should return two values, in case two records exist in the second DE. We have managed to use the lookup function (%%=Lookup('Contracts','CONTRACTNO','CUSTOMER_CODE',CustomerCode)=%%) but the issue is that only 1 record is returned in the personalization. Is there any way to have two values returned in case two entries exist in the lookup DE? Commented Sep 17, 2021 at 8:51
  • we just found that we maybe can achieve this with LooKupRows function and we are trying to implement this. If you have any guidelines to share we are more than happy to receive them. Commented Sep 17, 2021 at 9:05

1 Answer 1


After your clarification and as you already mentioned in the comments, you should use the LookupRows function to be able to receive more than 1 result of the lookup. Also, do remember that you can specify several conditions in both Lookup and LookupRows functions to get a more precise outcome (it could be 2 PKs for example).

Here is an example of what you might have in your case -

VAR @CustomerCode, @LookupDE1, @LookupRowsDE2, @rowCount, @i, @Contracno

SET @CustomerCode = AttributeValue("CUSTOMER_CODE") /* value from attribute or DE column in send context */
SET @LookupDE1 = Lookup("MainContacts", "CUSTOMER_CODE", "CUSTOMER_CODE", @CustomerCode)

SET @LookupRowsDE2 = LookupRows("Contracts", "CUSTOMER_CODE", @LookupDE1)
SET @rowCount = rowcount(@LookupRowsDE2)

IF @rowCount > 0 THEN

  FOR @i = 1 TO @rowCount DO

    /* Fields you want to retrieve based on the specified Primary Key */
    SET @Contracno = field(row(@LookupRowsDE2, @i), "CONTRACTNO")

    <!-- Outputting the results for each found match -->
    <br>Row: %%=v(@i)=%%, Contracno: %%=v(@Contracno)=%%

    %%[ NEXT @i ]%%

%%[ ELSE ]%%
No rows found
%%[ ENDIF ]%%
  • The problem is that we want to fetch values from a 2nd DE (Contracts) while at the same time we send the email from another table (MainContacts). So the problem is on how to perform the LookupRows function on the 2nd DE(Contracts) while we semd the email from the 1st DE(MainContacts) Commented Sep 17, 2021 at 9:58
  • If you have a relation between those 2 DEs, you can do a Lookup first. I update my answer.
    – Niko
    Commented Sep 17, 2021 at 10:04
  • The error we get is "The subscriber preview failed to generate. Review the details, correct all issues, and try again. Failed to convert parameter value from a String to a Int32. Input string was not in a correct format.". Do you have any info regarding this? Commented Sep 17, 2021 at 11:18
  • The problem seems to be with the preview and subscriber that you have chosen to render the preview. Cannot help you with that. However, please make sure that all field names, DE names, and chosen DE + subscribers for preview are correct.
    – Niko
    Commented Sep 17, 2021 at 12:28
  • Thanks a lot @Niko Commented Sep 17, 2021 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .