Copy link to clipboard
Copied
Hi there --
I have a database that holds subscription info. Based on the time of payment and the length of subscription, I calculate an accrued monthly amount, assign that amount to a variable, and assign it to a month on a Web page.
I want to tally up the totals for the columns that result. That means I'll need to add up several fields per record, and also add up all the records - like this:
Customer 1: Field 1 + Field 2 + Field 3
Customer 2: Field 1 + Field 2 + Field 3
... and so on - I want all those fields added together.
I can get what looks like the last record's fields summed by using <% = (Field1) + (Field2) + (Field3) %> but it doesn't tally up all the records.
It's possible to do, isn't it? Help?
Thanks!
Copy link to clipboard
Copied
If you are outputting all rows in a loop, then you can create variables to keep a running total. If you only ouput the totals, then total them within your SQL statement.
Copy link to clipboard
Copied
Thank you!
I am looping through the recordset. Can you tell me how I'd handle those variables? I can't quite get my head around it.
Fields 1, 2 and 3 are already variables calculated from the values in the database, and they're getting output into that recordset loop...
Copy link to clipboard
Copied
Create a variable(s) outside the loop. Then for every iteration, add the values of the columns of interest to the variable(s). When the loop is complete, output the value of those variables. That's it.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more