Cumulative measurement


I am trying to sum up the total hours spent in a geofence by a worker so i am measuring difference between each geofence out and geofence in and to have the cumulative result for the whole day i am using discrete statistics but the result coming out of discrete statistics is not logic, is there any other way to sump up multiple values received during the day other than discrete statistics?


you could create custom block that does the sum. This would be a fairly simple block. But Discrete Statistics is actually also quite simple. Here you can see an open-source version of the block:

Can you share how your model looks like? The “sample” and “reset” behavior of the block is a bit confusing so this could be the reason for the unexpected results

thanks, the model building blocks are:

  1. duration: calculated the difference in seconds between one location update event and its next one (I added a measurement for testing for this phase and the numbers are accurate)
  2. this number is converted into minutes using an expression and compared to a threshold (above 3), this one is also working correctly and breached is occurring correctly
  3. If breached is true, a gate opens and the number in minutes of #2 will be an input to ‘discrete statistics’ providing SUM in order to have cumulation of inputs. ‘discrete statistics’ sample is not connected and reset is connected to a crontimer which resets it end of day (2AM UTC). The output is an accurate number the 1st time it is used and then it starts missbehaving when cumulating more inputs and ‘discrete statistics’ are greater than expected . Sometimes it seems adding a single input twice and sometimes the number is completely weird and unexpected.

Could you share the exported model via a private message?

I shared it now

Hello, by the way we have a new finding related to the same model built in analytics builder:

we were facing inaccurate numbers (this time much less than expected) and after a long troubleshooting we found the following conclusion based on our simulations that we created for location updates

    • if time of alarm (received from device and mentioned as “device time”) is greater than time of platform then the alarm is being processed by analytics model
    • if time of alarm (received from device and mentioned as device time) is less than time of platform the alarm is discarded and not being processed by analytics model as if it happened in the past

it seems analytics model is processing alarms synchronously and when alarm time is before ‘cumulocity platform current time’ it is being dropped. Is it an accurate conclusion? and how much delay in seconds does cumulocity tolerate as an alarm delay? and how to tune it?