I am relatively new to using the Query function but I would like to understand what I'm doing wrong in the following scenario.

I would like to pull from a table with a Year field in column F and Month field in column G. The query pulls correctly when filtering column E and J but returns nothing once I add either column F or G. This is weird because the source table contains a lot of data for the conditions (verified by filtering the source table). Any idea what could be going wrong?


  • Welcome to Web Applications. Add some sample of columns E, F, G , J, M and O and the corresponding expected result.
    – Rubén
    Jan 21 at 22:13

Get rid of the single quotes around concatenations for numbers; otherwise the QUERY is looking for strings.


"... where ... F ="&A3&" and ..."


"... where ... F ='"&A3&'" and ..."

Same with "and G ="

  • Thank you however when I took out the single quotes I ended up with a #value...
    – DLL
    Jan 22 at 5:16
  • actually I just got it to work. amazing! I don't understand the reasoning behind why you need single quotes are for text matches and no single quotes for numbers but it works!
    – DLL
    Jan 22 at 5:26
  • There are three major data types: boolean, string and number. And code treats them differently. Quotes denote string values; think of a string as a way to tell a computer "treat this as exactly what I entered and don't assign it a value." So the string "44217" (in quotes) might be the zip code for Creston, Ohio (which we don't want to add, subtract or interpret; whereas the number 44217 (without quotes) is either the number forty-four-thousand-two-hundred-seventeen (with which math CAN be done) or a raw date (44217 days since December 31, 1899—which can also be manipulated with math).
    – Erik Tyler
    Jan 22 at 5:44
  • Continuing from above, the string "17" (in quotes) might be part of a street address (e.g., "17 Smith Lane"), where the number 17 (without quotes) might be a number of items in stock or an age—which we might want to do math with later. And in case you were interested, boolean values are TRUE and FALSE, which do NOT go in quotes, because they DO have interpreted meaning in code as well as assigned valued (FALSE being equal to 0 and TRUE being equal to 1).
    – Erik Tyler
    Jan 22 at 5:47
  • If my post answer addressed your original question then, which it sounds like it did, please take a moment to mark it as "Best Answer." This will let others know that this issue has been resolved, as well as helping future site visitors more easily find answers.
    – Erik Tyler
    Jan 22 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.