I would like the sumif statment to add the values in cells that are generated
by the sum formula.
I am using the following conditional if statement:
=SUM(IF($A$27:$A$38=P27,$L$27:$L$38,0)

Cells in column L add up other cells in column K to come up with a value.
However, the sumif statement does not give me the correct answer. It gives me
the total of that column instead of adding the corresponding values in the
cell that match cell P27.

P L Value of cell L column A28 is
2003
2003 =sum(k1:k5) 50
2003 =sum(k8:k17) 80
2004 =sum(k18:k22) 20

Instead of giving me an answer of 130 I get 150.