0
votes

I have a Simple spreadsheet with 2 rows:

ActualJAN | BudgetJAN | ActualFEB | BudgetFEB | ActualMAR | BudgetMAR ....
     100             200               300               400               500               600 ....

I'd like to sum ONLY the Budget columns up to the current month (Month(Today()).
Same for the Actual columns.

So if we're currently in February,
Budget to date would be: 600=200+400
Actual to date would be: 400=100+300

I just can't seem to get there, at least simply and elegantly.

4

4 Answers

1
votes

This is a non array formula that performs array like operations. As such large range references should be avoided or you will experience a slow down or potential crash of your system. For a small defined range works great so long as the formula is not repeated too many times either.

Additionally TODAY() is a volitile function which means the formula will recalculate whenever anything in the spreadsheet changes, not just when something related to the formula changes.

This formula is generalized a bit so your data can be located anywhere on your sheet and does not require rearrangement of your data.

To get your actual sum use the following:

=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="A"))

To get your Budget sum use the following:

=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="B"))

Change C4:H4 to suit your number range. ChangeC3:H3 to suit your column title range. Change C4 to be the first cell of your number range.

Caveat: Assumes maximum 12 months starting at January

Proof of concept:

POC

0
votes

I would recommend structuring your data differently. It would be an easier task if you arrayed everything vertically and divided your data into three columns. The first would be Category, which would be populated with either "Budget" or "Actual." The next column would be Month. After that, of course, you have the Value column. Then, use a basic SUMIF, like "=SUMIF(A1:A6,"Budget",C1:C6)." A1:A6 is the range Excel will scan for the desired variable. In this case, that variable is "Budget." Then, C1:C6 is the value that corresponds to a "Budget" month. That formula will give you the answer you want as long as you expand the SUMIF formula to include the full range of values, e.g., "SUMIF(A1:A317,"Budget",C1:C317)."

0
votes

So I think I understand what you're trying to do, I cannot make the entire formula without the rest of the spreadsheet but this is working currently:

For the Actual:

=IF(MONTH(TODAY())=1,A2,IF(MONTH(TODAY())=2,A2+C2,IF(MONTH(TODAY())=3,A2+C2+E2,"")))

For the Budget:

=IF(MONTH(TODAY())=1,B2,IF(MONTH(TODAY())=2,B2+D2,IF(MONTH(TODAY())=3,B2+D2+F2,"")))

Here is the spreadsheet I created to test:

Sample spreadsheet

If you give me the rest of the data I can complete the formula, basically all you would need to do is add more months to the formula and change the amounts it adds.

I am sure there is probably a more efficient way to accomplish this but this way works.

0
votes

I suggest a hidden row to control your dates. Say, January is in column C, enter [C1] =1, [D1] =C1, [E1] =C1+1, [F1] =E1. Select E1:F1 and copy to the right until December. Hide row 1.

In row 2 use these two formulas.

[C2] ="Actual" & UPPER(TEXT("1/" & C$1,"mmm"))

[D2] ="Budget" & UPPER(TEXT("1/" & D$1,"mmm"))

Select C2:D2 and copy to the right until December. This exercise isn't required because the resulting display is exactly what you already have. But producing this result with the help of formulas ensures freedom from error, and it is faster. As an added bonus you get a visual check of what's in the hidden row.

Now you can use this formula to extract totals from row 3 where you have your values.

=SUMIFS($C3:$Z3,$C$2:$Z$2,"Budget*",$C$1:$Z$1,"<="&MONTH(TODAY()))

Change "Budget" to "Actual" and the same formula will extract the actual amounts.