Search code examples
if-statementgoogle-sheetslambdasumgoogle-query-language

How can you add more sheet tabs to existing IF/SumIF Google Sheet formula?


I'm trying to use Google's monthly budget template and alter it so I can get a full view of the year. I have tabs Jan-Dec made but I can't figure out how to add them to the below formula. When I try, it tells me that the IF can only use 3. The areas Expenses and Income in the screenshot should total up the Amounts (column C) with their respective category (Column E).

The same would be said for income using Columns H and J.

=if(isblank($B36), "", sumif(January!$E:$E,$B36,January!$C:$C))

Here is the link to my sheet https://docs.google.com/spreadsheets/d/1MTL3xdN-0W4vS7e_yO1C4qkFAxlsxhx3SLXyml78qOc/edit?usp=sharing

enter image description here


Solution

  • delete E28:E41 and try in E28:

    =BYROW(B28:B41, LAMBDA(b, IF(b="",,
     IFERROR(QUERY({January!C:E; February!C:E; March!C:E; 
     April!C:E; May!C:E; June!C:E; July!C:E; August!C:E;
     September!C:E; October!C:E; November!C:E; December!C:E}, 
     "select sum(Col1) where Col3 = '"&b&"' label sum(Col1)''", ), 0))))
    

    enter image description here