I have a sheet (Training) listing information for all employees (over 4,000 rows) and I have a query function on another sheet (Search) that allows me to filter down based on criteria selected by my team. The selections and corresponding cells are:
Company - A3 : First Name - B3 : Last Name - C3 : Email - D3 : PO # - E3 : Class - F3
I need to build a query() that lets me filter using only criteria cells that have information, ignoring completely any criteria that are blank.
The Query() will work using a single criteria or multiple criteria (using "or" and "and") but the information we have won't always be consistent (may have last name but not first name, have email but not company etc.) so I want it to filter using ONLY the data that matches what's been entered by my team and ignore the criteria if the cell (A3:F3) is left blank.
The way the code is written now it includes rows that match ANY of the criteria (I wrote it that way to know I had references correct then was expanding the criteria). I need it to include rows that match only the exact criteria entered.
=Query({Training!A2:AS},"select Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11, Col12, Col13, Col14, Col15, Col16, Col17, Col19, Col21, Col23, Col25, Col27, Col29, Col31, Col32, Col34, Col37, Col38, Col40, Col42, Col43, Col44, Col45 where Col2 = '"& A3 &"' or Col30= '"& E3 &"' ",0)
To give an example of what I want. If my team enters the following critera into "Search" sheet:
(A3) Company - Metro : (B3) First Name - left blank : (C3) Last Name - left blank : (D3) Email - left blank : (E3) PO # - 123456 : (F3) Class - left blank
My current code will show any row that contains Metro in Col2 or 123456 in Col30. I want it to show rows that only contain BOTH Metro and John in them, ignoring rows that only match 1 criteria and ignoring the other criteria completely since they were left blank.
I've found a few things online that I thought would work, but either they ended up not being what I needed or I'm not versed enough in the function to make them work. Any help with an explanation for teaching purposes would be great.