1

I have the below code that outputs all the Daily_Volumes values for a individual subscriber based on subscriber key. How can it be updated to output a second field for each row its finds?

Eg: Currently it outputs Eg: 100kgMS/day, 200kgMS/day, 50kgMS/day when multiple rows of the same subscriber key is found.

What i need is it to output a second column from that subscriber row

Eg: Product A = 100kgMS/day, Product B = 200kgMS/day, Product C = 50kgMS/day Where Product A,B,C is data from column Product_Type

This is the code im currently using

%%[ 
var @rows, @row, @rowCount, @returnRows, @SubscriberKey, @i 
set @SubscriberKey = AttributeValue("_SubscriberKey") 


set @returnRows = -1 /* 0 means all, max 2000 */ 
set @rows = LookupOrderedRows("Data - Includes Volume", @returnRows, "Daily_Volume asc", "Daily_Volume asc", "Subscriber Key", @SubscriberKey) 
set @rowCount = rowcount(@rows) 

if @rowCount > 0 then 

  var @Daily_Volumes 
  set @Daily_Volumes = "" 

  for @i = 1 to @rowCount do 

     var @Daily_Volume 

     set @row = row(@rows,@i) /* get row based on counter */ 
     set @Daily_Volume = field(@row,"Daily_Volume") 

     if @i < @rowCount then 
        set @Daily_Volumes = concat(@Daily_Volumes, @Daily_Volume,"kgMS/day, ") 
     else 
        set @Daily_Volumes = concat(@Daily_Volumes, @Daily_Volume) 
     endif 

  next @i 

else 

   write(concat(" no rows found")) 

endif 

]%%

Your contracted quota is  %%=v(@Daily_Volumes)=%%

Thanks Andy

2

You should just be able to add a Product_Type field in your loop and then output it.

%%[ 
var @rows, @row, @rowCount, @returnRows, @SubscriberKey, @i 
set @SubscriberKey = AttributeValue("_SubscriberKey") 


set @returnRows = -1 /* 0 means all, max 2000 */ 
set @rows = LookupOrderedRows("Data - Includes Volume", @returnRows, "Daily_Volume asc", "Daily_Volume asc", "Subscriber Key", @SubscriberKey) 
set @rowCount = rowcount(@rows) 

if @rowCount > 0 then 

  var @Daily_Volumes 
  set @Daily_Volumes = "" 

  for @i = 1 to @rowCount do 

     var @Daily_Volume 
     var @Product_Type

     set @row = row(@rows,@i) /* get row based on counter */ 
     set @Daily_Volume = field(@row, "Daily_Volume") 
     set @Product_Type = field(@row, "Product_Type") 

     if @i < @rowCount then 
        set @Daily_Volumes = concat(@Daily_Volumes, @Product_Type, " = ", @Daily_Volume,"kgMS/day, ") 
     else 
        set @Daily_Volumes = concat(@Daily_Volumes, @Product_Type, " = ", @Daily_Volume) 
     endif 

  next @i 

else 

   write(concat(" no rows found")) 

endif 

]%%

Your contracted quota is  %%=v(@Daily_Volumes)=%%

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.