Here are the details of the project I'm working on:

  • I have an automated email workflow
  • The first step of automation is generating a new data extension (DX) based on a filter
  • I need to populate an email with data from each row of the filtered DX
  • This means looping through each row of the DX

I believe the only way to do this is to add a column to the filtered DX, like rowNum and then increment each row by 1, so then I can do:

FOR @cnt = 1 TO DataExtensionRowCount("DX") LookupRows("DX", "rowNum", @cnt) /* do stuff */ NEXT @cnt
The problem is that I would have to create this new rowNum column on the fly, either in the email at sendtime OR in a SQL query (not sure ET supports this though). I've tried UpsertDE() but if that's it then I can't seem to figure out the syntax.

Any thoughts? Let me know if you need any clarification/additional info.


We cannot add additional column in to the filter. I would suggest add Flagcolumn with default value to True in DataExtension itself so Filter DataExtension will generate a new data with Flag column value True.

Now, use LookupOrderedRows AmpScript function to retrieve each row of the filtered DX.

SET @DataCount = LookupOrderedRows("DX",0,"Any DX column name Desc","Flag","True")
For @i = 1 TO RowCount(@DataCount) Do
     /* Do your stuff */
Next @i

Hope this solution will help you!

| improve this answer | |
  • Thanks, this is essentially the conclusion I came to as well. – user24717 Sep 16 '15 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy