formula to calculate inventory - Search