Not sure if this is possible via AMPScript

I have a table that contains dupes, is it possible to set the second iPhone to blank in the list below so then i can hide that row so that the table only show unique products? will also need to run this check on all other products

Product - Iphone, Iphone, Ipad, Imac, Mac

Also is there a way to count all the product a customer has?

1 Answer 1


If you have to do this in AMPScript, you can do it like this -- as long as it's OK to have the rows ordered by Product:

var @i, @rows, @row, @productName, @prevProductName, @rowsToReturn

var @rowsToReturn = 0 /* up to 2000 */

SET @rows = LookupOrderedRows("SubscriberProducts" ,@rowsToReturn, "ProductName asc", "EmailAddress",emailaddr)

set @prevProductName = ""

FOR @i = 1 TO RowCount(@rows) DO

  set @row = Row(@rows,@i)
  set @ProductName = Field(@row, "ProductName")

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

     set @prevProductName = @productName



%%[ endif ]%%

%%[ next @i ]%%

This kind of de-duping and counting is best done before it gets to the email -- like with a Query Activity step before the send.


  • Thanks, so it best to de-dupe the data in SQL Query activity - thats what i thought. will look in to what options I have
    – Peter Ho
    Jan 25, 2017 at 14:21

You must log in to answer this question.

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