I'm using google sheets, and I found that this doesn't work:
=QUERY(CSV!1:1000,"select J, AA, AD where J<date'2004-01-01'")
But this does:
=QUERY(CSV!1:1000,"select J, AA, AD where J>date'1900-01-01' and not J>date'2004-01-01'")
Can someone please explain why I have to make my query more complicated to filter by date?
try:
=QUERY(CSV!1:1000, "select J,AA,AD where J < date'2004-01-01' and J is not null", )
Related
Data Sheet
Please assist a newbie with a query about query where 1 = Total Gross or Employers Cost based on the department and pay period.
So from the Data Sheet to a query on another sheet, I would be able to select February and Data it would produce Column C, D, I & J
Thanks in advance
Use this formula
=QUERY(Sheet1!A:J, "Select A, C, D, I, J Where A = '"&$B$3&"' ", 1)
Demo
I have a query in google sheets:
=QUERY('Depot Report'!D:Q, "SELECT I, J WHERE P ='"&AK4&"'")'
AK4 is a data validated list of numbers 1-40 which selects all I, J based on the value of AK4.
What I want is "all" in the list that will run the query:
=QUERY('Depot Report'!D:Q, "SELECT I, J")
Edit after your comments
The formula always work very well, but your problem in your sheet is:
Values in column P are not numbers because are formatted as text.
No problem. Solution is very easy.
SOLUTION
Select all column P and format from menu Automatic.
Also I changed formula a little for cell S12 for exactly what you need.
Only copy/paste formula now.
.
=QUERY('Depot Report'!D2:Q, "SELECT I, J WHERE 1=1"&IF(T4="All",""," AND P= "&T4&" "))
Use this formula
=QUERY('Depot Report'!D2:Q, "SELECT I, J WHERE 1=1"&IF(AK4="",""," AND P= "&AK4&" "))
I have a tab call (Data Import) where I have the whole raw data imported in google sheets, in the next tab I have my query that looks as below;
This is the query -> =QUERY('Data Import'!$I1:$O, A1, 1)
A1 is equal to -> ="SELECT K, O, J WHERE J >= "&F1&""
F1 is equal to -> 44196
The result I get is only the first row, but I want all the rows that contains the same date which are a total 25 plus the header with the column names.
Does anyone figures what I am doing wrong?
try in A1:
=QUERY('Data Import'!I1:O,
"SELECT K,O,J WHERE J >= "&F1*1, 1)
you could also solve it like:
=QUERY('Data Import'!I1:O,
"SELECT K,O,J WHERE J >= date '"&TEXT(F1, "yyyy-mm-dd")&"'", 1)
I wish to use a generalized projection as follows in a Google query with no success
=query('Form Responses 2'!A:N,"Select if(month(F)>6,year(F),year(F)-1) , N,B,C,D,E,F,G,H,I,J,K where F >= date '2011-07-01' and F <= date '2050-06-30' order by F desc, B")
Wishing to list the Year in column F in a required way.
Will be grateful if you can help me correct this.
You need to put the existing columns and your new column into an array
=arrayformula(query({A:N,if(isdate(F:F),if(month(F:F)>6,year(F:F),year(F:F)-1),F:F) },"Select Col15,Col14,Col2,Col3,Col4,Col5,Col7,Col8,Col9,Col10,Col11 where Col6 >= date '2011-07-01' and Col6 <= date '2050-06-30' order by Col6 desc, Col2",1))
I also had to use isdate() because if you have headers in your table the month() and year() functions will give an error.
According to the Google Help Section I should be able to reference a column in a QUERY by using the "column identifiers ... the one or two character column letter (A, B, C, ...)" - or in this case, G.
The goal of my query is simply to pull information into a new spreadsheet from columns H, J, and K of a different spreadsheet if G is equal to a certain name; in this case, William.
My query:
=QUERY( Survey!G2:K , "select G, H, J, K where G = 'William'" )
works when I use it to call information from a sheet in the same spreadsheet. The problem arises when I try to use this QUERY with IMPORTRANGE. I have used both of these formulas:
=QUERY(IMPORTRANGE("key","'Survey!G2:K'"),"SELECT G, H, J, K WHERE G='William'")
=QUERY(IMPORTRANGE("key","'Survey!Col7:Col11'"),"SELECT Col7, Col8, Col10, Col11 WHERE Col7='William'")
and both return errors. I have included a link to the error that appears for the first QUERY The second error says the same thing, with Col7 replacing G in the text.
What should I be calling the columns in the QUERY?
Is this error due to a problem in my IMPORTRANGE overall?
Please include a link to your sheet.
The Col notation should only go inside the QUERY, not the IMPORTRANGE.
Try this:
=query(importrange("Survey!G2:K"),"Select * where Col7 = 'William'")
This may not be but shows signs of being lack of authorsation. Try IMPORTRANGE on its own and see whether you need to grant access (once off) to the 'other' spreadsheet.