We categorify the inclusion–exclusion principle for partially ordered topological spaces and schemes to a filtration on the derived category of sheaves. As a consequence, we obtain functorial spectral sequences that generalize the two spectral sequences of a stratified space and certain Vassiliev-type spectral sequences; we also obtain Euler characteristic analogs in the Grothendieck ring of varieties. As an application, we give an algebro-geometric proof of Vakil and Wood's homological stability conjecture for the space of smooth hypersurface sections of a smooth projective variety. In characteristic zero this conjecture was previously established by Aumonier via topological methods.