If your report groups by sales order number then, instead of using a running total, sum the values in the ""ItemsWithStock"" detail field (if {IM_ItemWarehouse.QuantityOnHand}-{@QtyToShip}>0 then 1 else 0). I am not sure by your post if the user wants to count the line (ItemsWithStock) if the quantity to ship = 0. In my example, all lines were counted as long as the qty on hand exceeded the quantity to ship even if the qty to ship =0.