I am trying to calculate volume withdrawn from a chemical tank based on change in tank level. I am using PIAF analysis to perform the calculations using periodic configuration to calculate daily volume consumed from a tank. The equations are working fine for most of the time. The challenge is the tank gets refilled automatically based on level indicators, when this happen the result becomes erroneous. Please see below expressions and suggest if someone have a solution or better approach to solve this issue. Thanks in advance.