0

I have a field called travelinterestand data extension name called testforelavaran. i dont know how many values in that field, suppose if that field contains four values, (col1,col2,col3,col4) and i want to count the values using rowcount, by using for loop and i will concatenate all the four values by using semicolon

I have tried:

%%[ 
var @travelinterest, @rows, @rowCount,@interestsTemp
set @rows = LookupRows("testforelavaran","travelinterest", @lookupValue)
set @rowCount = rowcount(@rows)
for @i = 1 to @rowCount
set @interestsTemp = concat(
    iif(empty(@travelinterest[i]),'',concat(@travelinterest[i],';'))
]%%

but it is not working, please help me with AMPScript code,

My output will be - output value is %%(travelinterest)%% (col1;col2;col3;col4)

  • What error is it giving? – Samuel Dare Jul 10 '17 at 15:09
0

You can't reference row-set elements like that in AMPScript. You'll have to do something like this:

%%[ 

var @lookupValue, @travelinterest, @rows, @rowCount, @interestsTemp
set @lookupValue = AttributeValue("WHATEVERLOOKUPVALUEHERE")
set @rows = LookupRows("testforelavaran","WHATEVERLOOKUPCOLUMNHERE", @lookupValue)
set @rowCount = rowcount(@rows)
set @interestsTemp = ""

if rowCount > 0 then

    for @i = 1 to @rowCount
        set @row = row(@rows,1)
        set @travelinterest = field(@row,"travelinterest")
        output(concat("<br>@i: ", @i, ", @travelInterest: ", @travelInterest))
        set @interestsTemp = concat(@interestsTemp,";",@travelinterest)
    next @i

endif
]%%
%%=v(@interestsTemp)=%%

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.