Home > Back-end >  Formula Help SUM Based on Given Value
Formula Help SUM Based on Given Value

Time:03-06

i have data in Column A - Days and Column B - Sales i want calculate running total based on Days Value like

Column A      Column B
 Day1           150
 Day2           200
 Day3           175
 Day4           250

i want total running sum in Column E Based on Value in Column D

here i applied this formula to running sum based on cell value

=SUM($B$2:B2,INDEX($B$2:B5,MATCH($D$2,$A$2:A5,0)))

here i have getting wrong result like if i enter (Day3 in Cell D2 getting result in Cell E2 - 325) it's wrong

CodePudding user response:

The syntax is just a bit off, you should add up the range from B2 to the position found by the match, in this case B4:

=SUM($B$2:INDEX($B$2:$B$5,MATCH($D$2,$A$2:$A$5,0)))

This works because Index returns a reference and can be used as one end of a range.

enter image description here

  • Related