1

I got a DE with my users in, and a data relationshop to a survey DE with answers from the user. Each user can answer the survey multiple times, and therefor be in the survey DE many time.

Now i want to send a mail with the newest answers data in. If i just a normale Loopup() i will get the first row that matches the user. But it need to get the row with the newest Timestamp on.

%%=Lookup("EVALGO","Question_1","email",email)=%%

This returns the first rows that matches the email for the user, i need somehow to filter the rows, and return the newest (according to the Timestamp)

3

Use LookupOrderedRows(), specifying your data column DESC. Then, just select the first item.

  • But doesn't that just return a number? "Returns a specified number of rows", I'm not sure how to grap a value from the row returned – Bidstrup Sep 12 '15 at 20:40
  • No, you're misreading it. If you note the second parameter is the number of rows you want back. It's the "specified number". – Timothy Sep 13 '15 at 0:49
  • Aah of course :) okay so this 1 row I get you I store in a variable and then I loop through it? Or is it the Field(@row, "question_1") I need to use? Amp script is very new to me. – Bidstrup Sep 13 '15 at 6:19
1

Thanks for the help.

this worked:

%%[ 

Set @GroupRecords = LookupOrderedRows("EVALGO",0,"Timestamp Asc","email",email))  

If not empty(@GroupRecords) then  
    set @rowcount = Rowcount(@GroupRecords)  
    for @i = 1 to @rowcount  do  
        Set @row = Row(@GroupRecords,@i)  
        Set @TS = Field(@row,"Timestamp")  
        Set @Q1 = Field(@row,"Question_1")  
        Set @Q2 = Field(@row,"Question_2")  
        Set @Q3 = Field(@row,"Question_3")  
        Set @Q4 = Field(@row,"Question_4")  
        Set @Q5 = Field(@row,"Question_5")  
        Set @Average = Field(@row,"Average_score")  
    next @i  

ENDIF 

]%%

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.