0

The problem:

I have two sheets, Auto Expenses & Business Expenses (duplicate sheets with different categories of expenses) Column J represents the cost of an expenses Column F represents the date of the expense

I am trying to create a function that will add up all of the expenses between both sheets given a start date & an end date and iterate down the column

Here is the function I wrote:

=ArrayFormula(if(isblank(F2:F),"",SUMIFS('Auto Expenses'!$J$7:$J,'Auto Expenses'!$F$7:$F,">="&O2:O,'Auto Expenses'!$F$7:$F,"<="&P2:P)+SUMIFS('Business Expenses'!$J$7:$J,'Business Expenses'!$F$7:$F,">="&O2:O,'Business Expenses'!$F$7:$F, "<="&P2:P)))

O2:O is a list of start dates & P2:P is a list of end dates>

When I run the function, it will only return the first sum of the expenses and iterate all the way down with the same value.

What am I doing wrong?

If I use this function instead and drag is down, it gives the proper results, but I want it to iterate down the column automatically

=SUMIFS('Auto Expenses'!$J$7:$J,'Auto Expenses'!$F$7:$F,">="&O2,'Auto Expenses'!$F$7:$F, "<="&P2)+SUMIFS('Business Expenses'!$J$7:$J,'Business Expenses'!$F$7:$F,">="&O2,'Business Expenses'!$F$7:$F, "<="&P2)

Here is a link to a copy of the spreadsheet for reference: https://docs.google.com/spreadsheets/d/1Lbrvsrz90RSYhedwA8IkyoYlHqWy5Lw7Ngxw5eRjAKs/edit?usp=sharing[enter image description here][1]

4
  • 1
    SUMIFS is not supported by ARRAYFORMULA. Commented Dec 3, 2021 at 3:18
  • Unable to access sheet via link - plz make it shareable Commented Dec 3, 2021 at 8:25
  • @TomSharpe I have granted access to the spreadsheet now. You should be able to view & edit Commented Dec 3, 2021 at 14:38
  • @idfurw oh I forgot about sumifs not being supported by arrayformula. So then would I have to do a sumif for each condition and just add them all together? Commented Dec 3, 2021 at 14:39

1 Answer 1

0

Since your time intervals are all seven days, one approach is to develop a 2d array with 7 columns where each column represents a different day of the week, and use that in a sumif to get the totals for each day. Then use Mmult to sum across the 7 days:

=ArrayFormula(if(O2:O="",,mmult(sumif('Auto Expenses'!F7:F,O2:O+sequence(1,7,0),'Auto Expenses'!J7:J),sequence(7,1,1,0))))

enter image description here

Then do the same thing for business expenses (which isn't yet populated in your sample sheet).

Sign up to request clarification or add additional context in comments.

1 Comment

Wow I didn't even know =SEQUENCE was a function I could use! I'm new to learning about Google Sheets/Excel arrays so this is very helpful to know. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.