The Calculate action calculates a statistic about objects of a selected type, and returns it as a variable. Like the "Find" and "Select" actions, this action executes a query on the platform's underlying database, fetching all objects that fit the criteria supplied by the user. Unlike these actions, however, the Calculate action does not return the objects selected by the query; instead, it calculates one of five statistics about these objects:
Below are a few examples of the Calculate action:
The first example returns the number of trailers with a moving state of "Idle". The second returns the maximum temperature among all rooms in building "b". The last selects all device readings from the last 24 hours for the object associated with device "d", and calculates the average speed. Each of these statistics is then stored in a variable ("t_idle", "temp_max", "avg_speed", respectively), which can then be used by any action later in the logic chain of the Routine.