Search code examples
if-statementgoogle-sheetsfiltergoogle-sheets-formulagoogle-sheets-query

Filter formula for multiple cell references


How can I make it so the formula on E2 reads values entered in any of the search cells and displays it as results, considering I have a button to clear all search boxes and users are instructed to only search one box at a time and to press the button if multiple boxes are filled?

enter image description hereSee image

Here's my editable Spreadsheet

Much appreciated.


Solution

  • try:

    =IFNA(QUERY(A2:C4; "where A = '"&B6&"' 
                           or B = '"&B7&"' 
                           or C = '"&B8&"'"; 0))
    

    0


    I'd like results to be shown only if the data users look for are in the same row.

    =IFNA(QUERY(A2:C4; "where A = '"&B6&"' 
                          and B = '"&B7&"' 
                          and C = '"&B8&"'"; 0))
    

    UPDATE:

    =IFNA(QUERY(A2:C4; "where "&TEXTJOIN(" and "; 1; 
     IF(B6="";;"A = '"&B6&"'"); 
     IF(B7="";;"B = '"&B7&"'"); 
     IF(B8="";;"C = '"&B8&"'"))&""; 0))