Google Sheets – Sumif and Filter Using Regexmatch with Multiple Criteria

filterformulasgoogle sheetsgoogle-sheets-queryregex

I need to sum specific cells in 1 column (Q) based on if the other columns (R, S) have a certain word(s) within the cell.

For example in the picture if a cell in R or S contains the word toy or green, then it needs to sum the specified data from column Q.

I have tried using different variations of sumif-filter-regexmatch but I still can not get it to work with multiple conditions. If there is another set of formulas to use please show me.

Thank you!

P.S (I need the sum from the Q column not the count of cells)

Use this for reference

Best Answer

You can use the following query formula:

=QUERY(Q2:S11, "select sum(Q) where R matches '(.*green.*)|(.*toy.*)' 
                                 OR S matches '(.*green.*)|(.*toy.*)' label sum(Q)''")

sum query matches multiple words in multiple columns regex

About QUERY