Search code examples
arraysgoogle-sheetssumgoogle-sheets-formulagoogle-query-language

How to find the total result of selected category?


Im here with a query that in my sheet, I want to find the total sales of a selected category. for eg in that sheet if we select Audi and Feb from the dropdown list the H4 column must display the total sales happened for Audi in FEB month. please take a look to my sheet so that you will get clear what i want to say.

https://docs.google.com/spreadsheets/d/1Ec6tNevF5e3UF_AMFSUHgmlWwVibsEc6uMEGNDCKopQ/edit?usp=sharing

Thanks in advance


Solution

  • use:

    =IFERROR(SUM(INDEX(QUERY({D7:G}, "where 1=1 and "&
     TEXTJOIN(" and ", 1, 
     IF(D4="",,"Col1 = '"&D4&"'"),
     IF(E4="",,"Col2 = '"&E4&"'"),
     IF(F4="",,"Col3 = '"&F4&"'"))),,4)), 0)