I have a google spreadsheet which looks like this. Note that KeyColumn values are from a finite pool.
StartDate EndDate KeyColumn
01/01/2016 05/01/2016 Key1
05/01/2016 10/01/2016 Key2
11/01/2016 20/01/2016 Key1
They are sorted. Next StartDate is greater than or equal to the current EndDate.
What I want to do is creating the following sheet with a kind of lookup. Each key column can be created manually.
Date Key1 Key2
01/01/2016 True False
02/01/2016 True False
03/01/2016 True False
04/01/2016 True False
05/01/2016 True True
06/01/2016 False True
02/01/2016 is True for Key1 because it is in the range of the first row in the first table which has the value Key1.
05/01/2016 is True for Key1 and Key2 because it is in the range of the first row and the second row.
Is this possible in google spreadsheet without using any scripts? I couldn't find a way.
This can be accomplished with creative use of the filter and count functions:
i used query function to solve that the formula
=iferror(hlookup(B$8,transpose( QUERY({arrayformula(days($A$2:$B$4,)),$C$2:$C$4},"select Col3 where Col1<="& days($A9,) &" and Col2>= " & days($A9,) ,-1)),1,False)=B$8,False)
or
=iferror(hlookup(B$8,transpose(query($A$2:$C$4,"Select C Where toDate(A) < date '" & text(A9, "yyyy-mm-dd") & "' " & " and toDate(B) > date '" & text(A9, "yyyy-mm-dd") & "' ",-1)),1,False)=B$8,False)
Related
[![enter image description here][1]][1]
So I am trying to pull a query by date, but when I do exactly like the tutorials I found on the internet it just doesn't work,
i.e. :
=QUERY(Penjualan!$A$1:$H$136,"select A , B , D , H where B > date '"&TEXT(TODAY(),"yyyy-mm-dd")&"'",1)
or
=QUERY(Penjualan!A1:H; "select A , B , D , H where B = date '"&text(D1, "yyyy-mm-dd")&"'" )
does anyone know what is wrong?
try like this:
=TEXT(TODAY(); "yyyy-mm-dd")
=QUERY(Penjualan!A1:H;
"select A,B,D,H where B = date '"&TEXT(D1; "yyyy-mm-dd")&"'")
=QUERY(Penjualan!A1:H;
"select A,B,D,H where B > date '"&TEXT(TODAY(); "yyyy-mm-dd")&"'"; 1)
How do I re write this query for Google sheet, so that the dates in column B can be taken from a cell say X1 and X2
=QUERY(master!A:N,"select B,D,H where B>=date '2021-10-01' and B<=date '2021-10-31' and (E='3-MonoYarnSupply' or E='4-MultiYarnSupply') label B 'Date',D 'Particulars',H 'Quantity Supplied'")
Expected formula
=QUERY(master!A:N,"select B,D,H where B>X1 and B<=X2 and (E='3-MonoYarnSupply' or E='4-MultiYarnSupply') label B 'Date',D 'Particulars',H 'Quantity Supplied'")
Where X1 = 01-10-2021 and X2 = 31-10-2021
You can split the formula and use string concatenation logic to refer to other cells like this:
=QUERY(A:N,"select B,D,H where B>=date '" & TEXT(X1, "YYY-MM-DD") & "' and B<=date '" & TEXT(X2, "YYY-MM-DD") & "' and (E='3-MonoYarnSupply' or E='4-MultiYarnSupply') label B 'Date',D 'Particulars',H 'Quantity Supplied'")
B >= date '"&TEXT(X1,"yyyy-mm-dd")&"' and B <= date '"&TEXT(X3,"yyyy-mm-dd")&"'
Thank you #Gangula. Qualifying the date values as above in the query helped to achieve what I required. Thank you for your time.
What is wrong with this code?
It is supposed to only gather the data in the is range for cols 1,2,3,5,11 for the name Bob that contain False. In my results I'm getting data that are TRUE. If I change 'not Col25 = 'True' to Col25 = 'False', I get no results at all.
=QUERY(IMPORTRANGE(" "Master!A:AB"),
"select Col1,Col2,Col3,Col5,Col11
where Col11 = 'Bob'
AND not Col25 = 'TRUE'")
It doesn't look like you need to use importrange there.
Try the following formula:
=QUERY(Master!A:AB,
"select A,B,C,E,K
where K = 'Bob'
AND Y = FALSE")
Result on my sheet:
NOTE: Make sure that the FALSE and TRUE values are setted as automatic and not in plain text:
I have a query pulling from a large data list, and it works until I try to filter the data (Range Q) for two date ranges.
I've tried changing around the date format (yyyy/mm/dd, yyyy-mm-dd, etc), but it still does not seem to want to work. The value for $E$6 and $E$7 are pulling from data validation, and the Range Q is grabbing from a row with dd/mm/yyyy format.
=QUERY('Deal Data'!A1:X999,
"select B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X
where ("&IF($E$8 = "All", , "D = """&$E$8&""" and ") &
IF($E$9 = "All", , "C = """&$E$9&""" and ") &
IF($E$10 = "All", , "U = """&$E$10&""" and ") "
Q >= date """&TEXT($E$6,"dd/mm/yyyy")&"""
and Q <= date """&TEXT($E$7,"dd/mm/yyyy")""" and " &
("F = """&$E$11&""")"))
The formula works when I exclude the data range:
=QUERY('Deal Data'!A1:X999,
"select B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X
where ("&IF($E$8 = "All", , "D = """&$E$8&""" and ") &
IF($E$9 = "All", , "C = """&$E$9&""" and ") &
IF($E$10 = "All", , "U = """&$E$10&""" and ") &
("F = """&$E$11&""")"))`
The result I am getting is an #ERROR result.
Any help would be very appreciated!
this is how query should look like if you want to query out data between dates
=QUERY(A2:B, "select * where A >= date '"&TEXT(C1, "yyyy-mm-dd")&"'
and A <= date '"&TEXT(C2, "yyyy-mm-dd")&"'", 0)
I want to return 3 columns, A(description), 'D'(hard coded value of D), Q(date)
=query('Detailed Plan'!$A$2:$Q, "select A,'D',Q where D = date)
It returns the following results. Rows 2 and greater are exactly what I want and would be perfect if I didn't get the first row. How do I get a hard coded value into a column without "D"() showing up in the first row?
blank, "D"(), blank
Description, D, date
Description, D, date
Description, D, date
Thanks so much for any help that is provided.
You can use 'label' in the query string.
=query('Detailed Plan'!$A$2:$Q, "select A, D, Q where D = date label A 'Description', D 'Some value', Q 'Date' ", 0)
EDIT: if you don't need headers at all, try
=query('Detailed Plan'!$A$2:$Q, "select A, D, Q where D = date ", 0)