0

I'm trying to return a value from a DE based on a concatenated lookup, but am having some trouble.
I know how to concatenate Attribute Values, but not sure how to get that to lookup against the DE to return a value.
Customerid and userid both have duplicates and need to be concatenated to be unique.

Sendable DE

customerid userid email
art 5643 c@d.de
art 6643 r@d.fr
jup 5643 c@h.pt
kit 5643 c@d.se

Offertable

customerid userid offer
art 5643 100
art 6643 75
jup 5643 50
kit 5643 10
%%[

Var @customerid, @cid, @row, @rows, @userid, @uid,@cuid, @offer, @rowcount

Set @cid = AttributeValue("customerid")<br>
Set @uid = AttributeValue("userid")<br>
Set @cuid = Concat(@cid,@uid)

Set @rows = LookupRows("offertable", "offer", "customerid",@cid,"userid",@uid, @cuid)<br>
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
set @row = row(@rows,1) 
set @offer = field(@row,"offer")
else 
No rows found
endif
 ]%%

OFFER : %%=v(@offer)=%%
1
  • 1
    You should not concatenate the values, as this will search for the string in a single column. Instead, use LookupRows to lookup the values in both columns respectively, as described by Adam Spriggs here: sprignaturemoves.com/ampscript-lookup-examples Aug 3 at 8:50

1 Answer 1

1

You did a wrong syntax in LookupRows function. I would try this:

Set @rows = LookupRows("offertable", "customerid",@cid,"userid",@uid)

Full code:

%%[

Var @customerid, @cid, @row, @rows, @userid, @uid, @offer, @rowcount

Set @cid = AttributeValue("customerid")<br>
Set @uid = AttributeValue("userid")<br>

Set @rows = LookupRows("offertable", "customerid",@cid,"userid",@uid)<br>
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
set @row = row(@rows,1) 
set @offer = field(@row,"offer")
else 
No rows found
endif
]%%

OFFER : %%=v(@offer)=%%

And yes, you shouldn't concatenate the values.

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.