Let V be a Weyl module either for a reductive algebraic group G or for the corresponding quantum group U q . If G is defined over a field of positive characteristic p, respectively if q is a primitive lth root of unity (in an arbitrary field) then V has a Jantzen filtration V = V 0 ⊃ V 1 ⊃ · · · ⊃ V r = 0. The sum of the positive terms in this filtration satisfies a well-known sum formula.If T denotes a tilting module either for G or U q then we can similarly filter the space Hom G (V , T ), respectively Hom U q (V , T ) and there is a sum formula for the positive terms here as well.We give an easy and unified proof of these two (equivalent) sum formulas. Our approach is based on an Euler type identity which we show holds without any restrictions on p or l. In particular, we get rid of previous such restrictions in the tilting module case.