Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Resetting running Sum /
magic_bern
Hi All,
I have a calculated field that return the duration for which a flow temperature is below a certain threshold.
i.e. (for a threshold of 90 degc)
FlowTemp = 92 @ 00:00 0
FlowTemp = 90 @ 00:15 0
FlowTemp = 89 @ 00:30 15
FlowTemp = 90 @ 00:45 0
FlowTemp = 92 @ 01:00 0
FlowTemp = 90 @ 00:15 0
FlowTemp = 85 @ 01:30 15
FlowTemp = 87 @ 01:45 15
we can see that at 00:30, 01:30 & 01:45 the flow temp was outsite the threshold. the last value above is my calculated value that return how long the it was out of the threshold for (usually 15 minutes as we normally take the reading every 15 minute).
at the end of the report i do a running sum of my duration column to see how many minutes/hours were out for the month. however because we get penalise if the temperature is out for 24 consecutive hours, i want my report to only do a running count for consecutive 15 minutes, so whenever i go from 15 to 0 i would like the running sum to be reset to 0 and only fo a count when i have consecutive 15 minute for a full day.
Find more posts tagged with
Comments
mwilliams
I think I'm a little confused on the running count you want to do? How would you want your running count to look on the above data?
magic_bern
Hi MWilliams,
Thanks for the quick reply
for the above data, i would like it to be 0.
i am suppose to deliver water at a certain temperature and i have a control system that monitors the temperature putting more heat whenever i am out of the threshold. i get penalise by the customer if i am unable to deliver water at the appropriate temperature for 24 consecutive hours. However if i am out for 15 minute then go back to the correct temperature the clock is reset. (i could be out for 20hrs every day and not incur the penaly as long as on the 24th hour the temp was corect)
my database has a quaterly reading of flow temperature reading and what i need to do i diplay the temperature
have a column on the right indication whether is it within the range, if not display by how many degrees and for how long it is out of range (usually 15 minutes) and finally calculate how many days for which we were unable to meet the requirement for 24 consecutive hours
Thanks
mwilliams
Ok, I gotcha now. What you'll need to do (or at least one way to do it) is to create a variable in your dataSet beforeOpen method to count consecutive checks out of range, i.e. consecutiveChecks=0;
Also, create another variable in beforeOpen to increment if you reach the threshold of 24 hours, which would be 96 out of range checks in a row if checking every 15 minutes, i.e. penaltyDays=0;
Then, in a computed column in your dataSet, you could increment consecutive checks if out of the temp range for a given row. If you reach 96 out in a row, you would increment penaltyDays and reset your consecutiveChecks variable to 0. If you get back in range before you reach a count of 96, then you'd just reset the consecutiveChecks variable to 0 without incrementing your penaltyDays variable. Then, you'd return the penaltyDays variable as your column output to show the running total of 24 hour periods out of range. Hope this makes sense.
If you really only care about the final value and not the running count of pentaltyDays, you wouldn't need to do a computed column, you could initialize the 2 variables in the initialize method and put your script in the onCreate event of your table detail row and recall your penaltyDays variable in a dynamic textbox where needed.
magic_bern
Thank you very much, that is exactly what i wanted to do<br />
and the explaination was brill. here is my code for someone else in the future that might have the same problem<br />
i initialise the two variable in the before open<br />
consecutiveChecks =0;<br />
penaltyDays = 0;<br />
the create a data item in which i entered the following code:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>{
if (row["variation"]!=0){
++consecutiveChecks;
} else {
consecutiveChecks = 0;}
if (consecutiveChecks ==96){
++penaltyDays;
consecutiveChecks = 0;
}
}
consecutiveChecks;</pre>
that was because i wanted to display the count. then in the footer row i added another data item to display penaltyDays;<br />
<br />
Thanks again.
mwilliams
Not a problem. Glad to help!