Editor’s note: This is part of our blog series on getting to know AutoTag better. Here’s another useful feature you may have overlooked.
Did you know that AutoTag has a custom function that allows you to easily calculate a running total?
What exactly do we mean by “running total,” you ask? Allow me to explain.
Let’s say you are using a forEach tag to create a report of all products on order with a total dollar amount at the end of the report. The forEach tag is fetching this data from your data source at the time it is run, and you are running the report weekly.
Each week, the data for products on order is going to change. How to get an updated “running total” of all products on order each time you run the report?
By using the ADDTOTAL/GETTOTAL functions in AutoTag of course!
Using the ADDTOTAL/GETTOTAL Function
Here’s our sample template:
In our table above, the last column has an Out tag called [ExtendedPrice]. This tag is multiplying the [UnitsOnOrder] with the [UnitPrice], and both items are being dynamically generated from the data source.
To get our Product Total in dollars, we need to get a running total of the Extended Price column as it expands in the forEach loop at the time the report is generated.
We can do this in five steps:
- Set a variable name for the number the running total will based on.
- Create an Out tag that will hold your running total.
- Set up your ADDTOTAL function, which will calculate your running total.
- Create an Out tag that will hold your GETTOTAL function.
- Set up your GETTOTAL function, which will print your running total to your report.
That is all there is to it!
Now when you run the sample, you will have a Product Total based on the data that is returned by the forEach.
The Whole “Did You Know?” Series
Remember, you can receive the entire series in your email inbox by subscribing to our company blog here:
Author: Valerie Schilling
Valerie is passionate about people. Her strengths, with many years in the tech industry, are deeply rooted in relating and communicating. Valerie has an unparalleled tenacity to ensure the people she works with get what they need. Even if your problem is not solved immediately, your day will be brightened by her intelligent and cheerful demeanor.
Other posts by Valerie Schilling