How can I - if possible - using Analytics, calculate the consumption of a liquid extracted from a tank that empties and fills several times in the period to be measured? The only tag I have is the tank level tag.

The single way I know how to do it is by going through the level data in a loop, comparing them with the previous and keeping the maximum and minimum, but Analytics does not allow me to use loops, or at least I don't see how to do it.

Thanks in advance.

Regards.

Emilio Sancha

Thinking out loud here a bit.... Let's assume you have a level sensor that can provide data at a sufficient resolution, and you have the geometry of the tank and density of the fluid so you can covert level to volume. You can create an analysis that translate level measurement to volume and write that result to an output PI Point. Then you would need another analysis to extract the total out of this output PI Point. You will need to account for the filling operation in the logic of your analysis - for example if the level is rising then you have a filling operation.

Bear in mind that your calculation will not be extremely accurate because you may be filling and extracting at the same time so if you're only using the level measurement, you're not going to be able to know exactly how much the level changed due to extraction, unless you have an accurate volume measure of how much you're filling.