You can use the IF function to perform many formulas.

So for sums

If(A2="X", SUM(B:B),"")

or

If(A2="Y", SUM(B:B),"")

or

If(A2=8, SUM(B:B), "")

etc etc

Or you can combine them

IF(A2=8, SUM(B:B), IF(A=9, SUM(B:B), ""))

Where B:B in all cases is the range to SUM

As for your second part, again a IF will work.

=IF(B2>=C2, E2, "")

Bit harder to type without understanding how Col E and F are calculated.