I currently have an AMPScript block which is looking up values based on subscriberkey/client email, based on this displaying the results in an output table in the body of the email. (this is being done via LookupOrderedRows)

However, i'm also looking at how to exclude particular rows based on a value within that data extension.

Example of table:

| SubscriberKey | Email | Order# | Value | 
|12093801923 |[email protected] |1-000001 |TRUE |
|12093801923 |[email protected] |1-000002 |TRUE |
|12093801923 |[email protected] |1-000003 |FALSE |
|12093801923 |[email protected] |1-000004 |FALSE |
|12093801923 |[email protected] |1-000005 |TRUE |

By using LookupOrderedRows normally, it would return all 5 matched rows when subscriber key 12093801923 is used, however i want to exclude any records where the FALSE value is present and only show the TRUE records.

I've attempted to use a secondary LookupOrderedRows statement using something like:

SET @rowsexcludecount = LookupOrderedRows("Data_Extension"
, @numRowsToReturn
, "Order# asc, Email asc, Value asc"
, "SubscriberKey"
,"FALSE" )

and further down the ampscript block:

IF @rowCount > 0 and @rowsexcludecount !> 1 THEN 
FOR @i = 1 TO @rowCount DO

however im finding that all values / rows are being returned in the AmpScript block, where i only want the rows with a TRUE value to be displayed.

The backing data extension which the ampscript draws from is updated hourly ensuring that any records / values will be accurate and will continually fluid with values (in the value column)


1 Answer 1


Just add the additional conditions after a comma:

LookupOrderedRows("Data_Extension", @numRowsToReturn, "Order# asc, Email asc, Value asc", "SubscriberKey", @subscriberkey, "Value","TRUE" )

You must log in to answer this question.

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