Ubidots Community

Count devices based on a variable value

hi everyone,

I have 10 devices which collects data of grid status. now i want to show number of devices Gridoff and Grid on.

for example : if 6 devices grid is off. i want to show this number on Dashboard,

how can i count the devices based on variable values?

Hello @faisalaziz

I hope everything is going well.

First and foremost, taking into account that your devices send ‘1’ when the Grid is on and ‘0’ when the Grid is off. You can create two synthetic variables to calculate the number of devices in On and Off status, in this order of ideas, the operation for each variable should be set as follows:

GridOn—> fill_missing(grid1+grid2+...+grid10)

GridOff—> fill_missing(10-grid1+grid2+...+grid10)

You have to bear in mind that the “fill_missing” function is only available for IoT Entreprenour plans and above. This function will help you to compute an expression containing multiple variables with different timestamps, to extend your knowledge about the synthetic variables, please click the following hyperlink: SyntheticVariables.

All the best,

– Leonardo