0

I wanted some help for an AMPscript function where i get an error. I have a data extension with some information like : Number of points Amount Transations

I need to display on this email the amount of money they need to go on the next step (like VIP)

So i need to do two functions :

  • 5000 - Number of points = Number of points that i need to go on the next step
  • Number of points that i need to go on the next step / 20 = amount of $ that i need to spend to go on the next step.

I have this AMPscript :

SET @rowSet = LookupOrderedRows("Loyalty", 0, "Points Asc", "SubscriberKey", _SubscriberKey) 
SET @rowCount = rowcount(@rowSet)

for @i = 1 to @rowCount do 
    var @nombrePointsCumul, @montantTotalTransactions, @pointManquant, @dollarManquant
    SET @row = row(@rowSet, @i)

    SET @nombrePointsCumul = field(@row,"Points") 
    SET @montantTotalTransactions = field(@row,"Transactions") 

    SET @pointManquant = Subtract(5000, @nombrePointsCumul)
    SET @dollarManquant = Divide(@pointManquant, 20)
next @i
  • What error are you receiving? – Gortonington Jan 23 '18 at 20:22
0

For debugging purposes, I'd recommend doing an output() of values used in your calculations. I'm guessing your issues are data related (e.g. trying to do calculations on values that are not numbers).

%%[

   SET @rowSet = LookupOrderedRows("Loyalty", 0, "Points Asc", "SubscriberKey", _SubscriberKey) 
   SET @rowCount = rowcount(@rowSet)

   for @i = 1 to @rowCount do 

       var @nombrePointsCumul, @montantTotalTransactions, @pointManquant, @dollarManquant
       SET @row = row(@rowSet, @i)

       SET @nombrePointsCumul = field(@row,"Points") 
       SET @montantTotalTransactions = field(@row,"Transactions") 

       output(concat("<br>nombrePointsCumul: ",@pointManquant))
       output(concat("<br>montantTotalTransactions: ",@montantTotalTransactions))

       SET @pointManquant = Subtract(5000, @nombrePointsCumul)
       SET @dollarManquant = Divide(@pointManquant, 20)
   next @i

   ]%%

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.