Excel formula to find sum of difference

excelexcel-formula

I have excel sheet with 2 columns: baseline, current.
the baseline if base prices and the current is real price.
for example:

base | curr
-----|-----
10   | 15
8    | 8
9    | 5
1    | 2
-----|-----
27   | 28

Now, I need the difference if HIGHER current prices.. in our example, the first and last line have bigger current price, so i need the formula to return 6 (=15-10+2-1).

is there any way to do it in excel formula? I need to loop on all the rows and mark the curr>base rows, and then do the sum(curr-base) for everyone of the results.

I tried it with sumproduct, and other functions (sumifs and such) with no help…

any idea how to solve this?

Thanks!

Best Answer

If you don't like those -- you can also get the formula this way:

=SUMPRODUCT((B1:B3>A1:A3)*(B1:B3-A1:A3))

Note: the * replaced the ,

Related Topic