3

Is it possible if I can print multiple values from Lookup(). So for example I want to print following values in email;

Address 1 City State

Here is my code but seems it is not working.

%%=Lookup("Policy","Address 1","City","State","PolicyNumber",PolicyNumber)=%%

Is there a way to have a one lookup done and we can print multiple values from DE.

I tried creating multiple lookup values and it works, but it does not seems to me an effiecent way. For example the following method work.

%%=Lookup("Policy","Address 1","PolicyNumber",PolicyNumber)=%%
%%=Lookup("Policy","City","PolicyNumber",PolicyNumber)=%%
%%=Lookup("Policy","State","PolicyNumber",PolicyNumber)=%%
2

As @Timothy mentioned, you will need to utilize a block of AMPscript for this.

What you need to do is create a rowset via LookupOrderedRows() or LookupRows() functions.

After this you would use Row() to select which row and then Field() to select the specific field you want.

See below sample:

%%[
SET @PolicyNumber = AttributeValue("PolicyNumber")

SET @Rows = LookupRows("Policy", "PolicyNumber", @PolicyNumber)

SET @Row = ROW(@Rows, 1)

SET @Address = Field(@Row, "Address")
SET @City = Field(@Row, "City")
SET @State = Field(@Row, "State")
]%%
Address: %%=v(@Address)=%% <br />
City: %%=v(@City)=%%<br />
State: %%=v(@State)=%%<br />
  • 1
    It's great... I just have to fix one thing that is SET @Row = ROW(@Rows, 1) – Sohail Mar 2 '18 at 15:27
5

You're going to need a larger AMPscript code block to do it. Have a look at user Adam Spriggs blog at https://sprignaturemoves.com/ampscript-lookup-examples/

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.