0

I have this query that I am trying to add a condition to to filter out the results of a report given a time frame (time frame in my sheet is N2 and N3)

What I have now is the following and it works like a charm:

=QUERY('Report'!$A$2:$I; "Select B Where A = '"&$B28&"'");"Nothing to show")

No I want to add a condition to filter out only the results given my time period in N2 (start date) and N3 (end date). My dates in the reports are in column D. I did the following but it's not working:

=QUERY('Report'!$A$2:$I; "Select B Where A = '"&$B12&"';Select D where D >= date '"&$N$2&"' and D <= date '"&$N$3&"'");"Nothing to show")

What am I doing wrong?

1 Answer 1

0

Your query syntax is wrong. Try the following QUERY() formula-

=QUERY('Report'!$A$2:$I; "Select B Where A = '"&$B12&"' and D>= date '" &TEXT(N2,"yyyy-mm-dd")& "' and D<= date '" & TEXT(N3,"yyyy-mm-dd") & "'",1)
Sign up to request clarification or add additional context in comments.

4 Comments

I just used this using dd-mm-yyyy format (because that is my date format) and I get an error. =QUERY('MASTER Pending Opps'!$A$2:$I; "Select B Where A = '"&$B12&"' and D>= date '" &TEXT(N2 ,"dd-mm-yyyy")& "' and D<= date '" & TEXT(N3 ,"dd-mm-yyyy") & "'",1)
@A.Be Did you with "yyyy-mm-dd" because google-sheet use that format?
I actually tried both formats and they both give me an error
I just typed everything in manually and with a slight change in the formula, it's working now: =QUERY('MASTER Report'!$A$2:$I; "Select B Where A = '"&$B12&"' and D>= date '"&TEXT(N2;"yyyy-mm-dd")&"' and D<= date '"&TEXT(N3;"yyyy-mm-dd")&"'")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.