Search code examples
google-sheetsgoogle-sheets-formula

Google Sheets - Trying to create a SUM of earnings per MONTH & per YEAR


I'm new to all excel google sheet and I was tasked to creat a sheet in which i have a tab/sheet called "Payments" where I record payments from jobs along with other info like date.
I want to create another tab called "Statistics" where I want to SUM all earnings per specific month that is seperate for each year.

I am currently trying to use =ArrayFormula(SUMIF(MONTH(Payments!E2:E500)&YEAR(Payments!F2:F500),"="&MONTH("April")&YEAR("2023"),Payments!H2:H500)), but not sure why this doesn't work out.

Can you please help?

Link to the sheet


Solution

  • With MakeArray you can navigate through your headers with the help of index and the coordinates. And I used LAMBDA and BYCOL for the totals:

    =LAMBDA(arr,{arr;BYCOL(arr,LAMBDA(each,SUM(each)))})(MAKEARRAY(12,COUNTA(B1:G1),LAMBDA(r,c,SUMIFS(Payments!H2:H500,Payments!E2:E500,INDEX(A2:A13,R),Payments!F2:F500,INDEX(B1:G1,c)))))
    

    enter image description here