还应该明确一点,上月结存是截止到上月止的结存?还是只是上一个月的进出结存?
如果是截止到上月止的进出结存:
dr("上月结存_数量") = dt.Compute("Sum(入库数量)",Filter & "And [入库月份] <" & e.DataRow("月份") ) - dt.Compute("Sum(出库数量)",Filter & "And [出库月份] <" & e.DataRow("月份"))
如果仅仅统计上月的进出结存:
dr("上月结存_数量") = dt.Compute("Sum(入库数量)",Filter & "And [入库月份] =" & e.DataRow("月份")-1) - dt.Compute("Sum(出库数量)",Filter & "And [出库月份] =" & e.DataRow("月份") -1)