Search code examples
google-sheetsspreadsheetgoogle-sheets-query

Google sheets sum if within specific week


I have a Google Sheets budget and I am trying to write something to keep track of how much money I have spent in a specific week.

Link to my example budget below. https://docs.google.com/spreadsheets/d/15HP24iDd-kZ-MydKwgbMCoG0rCHN_DNOcBZsm0HhKQ0/edit?usp=sharing

I am already using sumif() to say, if the entry's CATEGORY says "Gas" then add theAMOUNT to the Gas row in the table. I want to add another parameter that will sum the amounts if the entry's CATEGORY says Gas AND is within the specified week above the table...(WEEK 31).

I hope this makes sense if you need more clarification I will try my best to do so.


Solution

  • As Diego suggested, SUMIFS()should work. Example

    =sumifs($C$4:$C$9, $D$4:$D$9, "=week "&$I$3, $B$4:$B$9,$F4)
    

    An alternative would be to use sumproduct().

    =sumproduct($D$4:$D$9="week "&$I$3, $B$4:$B$9=$F4, $C$4:$C$9)
    

    You should be able to fill down this formula (as far as needed) for the other categories.