|
|
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?
|
|
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: HTH- TNG Support
|
|
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?
|
|
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.
|
|
|
TNG |