Cumulative Data Options · View
IDEA STUDY
Posted: Saturday, June 28, 2008 10:15:12 PM
Rank: Newbie

Joined: 6/17/2008
Posts: 3
I am creating a template where I want a view to show the total number of miles walked since beginning an exercise program. Under Data to Track, I have "Distance Walked" and under views I have created "Cumulative Distance." I have selected SUM as the aggregation method, but it only adds up the number of miles walked in one day. How do I make the data cumulatively add up?
TNG Support
Posted: Sunday, June 29, 2008 8:51:42 AM

Rank: Advanced Member

Joined: 1/11/2008
Posts: 14
For your view and the series (Distance Walked) where you selected the SUM aggregation method --> select the "Vertical Data" tab and change the fields to the following:

Source: Calculation
Axis: Primary
CalculationType:Formula

Formula:

Code:

var total;

if(!TNGState["DistanceTotal"])
  TNGState["DistanceTotal"] = 0;

total = TNGState["DistanceTotal"];
total += {M};
TNGState["DistanceTotal"] = total;

total;



That will give you an increasing, cumulative total as the days progress. If you wanted just the all time total not a cumulative by day, you would do the same thing above on the "Horizontal Data" tab but your formula would be:

Code:

'Total Distance'



HTH- TNG Support
IDEA STUDY
Posted: Sunday, June 29, 2008 12:25:50 PM
Rank: Newbie

Joined: 6/17/2008
Posts: 3
Thank you so much for your help! But I am still having trouble...I put the formula in, but the data is not adding up right. For instance, the first day a person walked 1000 steps during 1 period and then another 1000 steps during another period in the same day. So the total should be 2000 steps, but the data point is showing up as 3000 steps. The data is cumulatively adding up, but it is not accurately adding up day by day. Is there a problem because there is more than 1 value per data point?
TNG Support
Posted: Sunday, June 29, 2008 9:01:45 PM

Rank: Advanced Member

Joined: 1/11/2008
Posts: 14
Whoops! Change the aggregation method from SUM to MAX and then the formula will work, sorry about that. The formula is doing the summarizing for you so we only want the end result for the day (which will always be the MAX). When it was set to SUM both the chart and the formula were trying to sum up the values.
Users browsing this topic
TNG


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Track-n-Graph, Track-n-Graph PRO, TNG Tracker, TNG Tracker Catalog, and TNG Tracker Template are all trade marks of Kamacho LLC.