0

EDIT: Works like a charm with this code. I'd like to add a new condition to the

if empty(@prevProductName) or @productName != @prevProductName then

set @prevProductName = @productName

I tried

if empty(@prevProductName) or @productName!= @last_productname or @productName != @prevProductName then

set @prevProductName = @productName

But it broke all the code (my products appeared again in double) Do I miss something?

END OF EDIT

I've got a new ampscript question:
Is it possible to use the function lookuporderedrows in combination with the if statement so I can exclude specific rows ?

More precisely, this is my code:

set @SAME_REGION_ROWS =
Lookuporderedrows("PRODUCTS","5","SORT_ORDER_FR DESC","REGION_ID",LAST_STAY_REGION)

%%=FIELD(ROW(@SAME_REGION_ROWS,1), "HOTEL_NAME") =%% 
%%=FIELD(ROW(@SAME_REGION_ROWS,2), "HOTEL_NAME") =%% 
%%=FIELD(ROW(@SAME_REGION_ROWS,3), "HOTEL_NAME") =%% 

A same HOTEL_NAME can be found several times in my table. I'd like to prevent it to appear several time in my email

So can I have something like:

set @SAME_REGION_ROWS =
Lookuporderedrows("PRODUCTS","5","SORT_ORDER_FR DESC","REGION_ID",LAST_STAY_REGION)

%%=FIELD(ROW(@SAME_REGION_ROWS,1), "HOTEL_NAME") =%% 
IF 
%%=FIELD(ROW(@SAME_REGION_ROWS,2), "HOTEL_NAME") =%%  = %%=FIELD(ROW(@SAME_REGION_ROWS,1), "HOTEL_NAME") =%% THEN
%%=FIELD(ROW(@SAME_REGION_ROWS,3), "HOTEL_NAME") =%% 
ELSE

%%=FIELD(ROW(@SAME_REGION_ROWS,2), "HOTEL_NAME") =%% 

But it doesn't seem really easy to read/implement if I go until 20 HOTEL_NAME for instance.

1 Answer 1

1

Adam Spriggs has an outline on github on how you can use lookuporderedrows to dedupe rows of data https://gist.github.com/wvpv/0080b50d7ea04c6300159d853bc44d9f

Quite elegant really.

You must log in to answer this question.

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