Search code examples
arraysgoogle-sheetssumvlookupgoogle-query-language

Sum value of col 3 based on col 1 and col 2 value


I want to sum value of col3 based on col1 and col2

here is the link of dummy data sheet in which I have shown sample table according to which I want sum of col 3 please guys check the sheet and suggest me some solution for it. https://docs.google.com/spreadsheets/d/1_MeiySJHI8OD84BPDOj_z57My-TXbs2ey4AOkQP3zug/edit?usp=sharing


Solution

  • use QUERY:

    =QUERY(A:C; "select A,B,sum(C) where A is not null group by A,B label sum(C)''")
    

    update:

    ={"result"; INDEX(IF(COUNTIFS(A2:A&" "&B2:B, A2:A&" "&B2:B, ROW(A2:A), "<="&ROW(A2:A))=1, 
     IFNA(VLOOKUP(A2:A&" "&B2:B, 
     QUERY({A2:A&" "&B2:B, C2:C}, 
     "select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''"), 2, 0)), ))}
    

    enter image description here