Search code examples
arraysgoogle-sheetssumnumber-formattingcumulative-sum

Get the total amount charged based on number of months


I'm having a hard time describing this one thus Googlage isn't helping.

I get charged $0.33/unit/month for warehouse space. Let's say I have 100 units I send to the warehouse. I expect this SKU to sell at 3 units/month. How much would I have paid in total when they all sell out?

The data looks like this:

End of Month    Quantity Sold   Total Charge
1               97              $32.01
2               94              $31.02
3               91              $30.03
4               88              $29.04
5               85              $28.05
6               82              $27.06
....

The number I want is the sum of each Total Charge cell.


Solution

  • try:

    =INDEX(TEXT(UNIQUE(IF(
     SEQUENCE(ROUNDUP(100/3)+3, 1, 100, -3)<0, 0, 
     SEQUENCE(ROUNDUP(100/3)+3, 1, 100, -3))), {"#", "#"})*{1, 0.33})
    

    enter image description here

    so the total is: $566.61

    enter image description here


    update:

    =SUM(INDEX(TEXT(UNIQUE(IF(
     SEQUENCE(ROUNDUP(100/3)+3, 1, 100, -3)<0, 0, 
     SEQUENCE(ROUNDUP(100/3)+3, 1, 100, -3))), {"#", "#"})*{1, 0.33},,2))