See attached qvw. As far as I can tell you did not give enough information. You didn't mention that Serialnr also needs to be considered. And there's probably something else since your table contains 0 for Itemnr 405015 in Warehouse 1 with Serialnr 1 on 4/17/2014. And that date is 27 days after 3/21/2014. So what's the reason there's a 0 instead of 27?