google sheets query date only brings one row result - google-sheets

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)

Related

Google Sheets, Count Text Entries In One Row Based on Criteria, Only Using the Last 4 row Entries as the Range, Excluding Blanks

In Google Sheets, I am trying to count the last 4 entries of specific text entries in one row that matches the text criteria based of another cell.
A
B
C
D
E
F
G
H
I
J (criteria)
K (results
X
Y
X
Y
Y
X
X
2
Criteria in cell J would be X, and results in cell K would be 2 (H+D).
Criteria for Y could also be set somewhere, and results would be 2(G+E).
The sample data must be only the last four entries in the row. As additional data is entered, the formula must account for only using the last four entries.
Anyone have a solution?
Thanks!!
Try
=ArrayFormula(countif(query(transpose({(A2:I2);column(A2:I2)}),"select Col1 where Col1 is not null order by Col2 desc limit 4"),J2))

Google sheets - find last value column index and get value from another row in that index + 1

I have the following sheet:
https://docs.google.com/spreadsheets/d/1GcC47i7193Hjt0QbTQ5OT_2SZQjPO_4wKmKKMwy_hQE/edit?usp=sharing
I need to get the date (from row 1) for each of the products (col a) corresponding with the col one after the last value in each row.
EG
For product A it would be 1/2/2021
For product B it would be 1/3/2021
To raise the limitation of the VLOOKUP formula by JPV,
Assuming there's only one "D" per row
you can use the following for any number of x's in any number of rows
={"Product","Date";
QUERY(INDEX(SPLIT(FLATTEN(IF(B2:D6="x", A2:A6&"_"&B1:D1,)),"_")),
"select Col1, max(Col2) where Col2 is not null
group by Col1 label max(Col2) '' ",0)}
Assuming there's only one "D" per row, in B8 try
=filter($B$1:$D$1, filter($B$1:$D$6, $A$1:$A$6=$A8)="D")
and fill down.
For a single formula (array output) try in B8
=INDEX(VLOOKUP(A8:A12, SPLIT(FLATTEN(IF(B2:D6="D", A2:A6&"_"&B1:D1,)), "_"), 2, 0))
See if that helps?

Google Sheets Query - Changing Query Data Range Based using a reference cell

I have seen the use of a reference cell to take the query place of the function.
For example:
Instead of A4 containing the entire function:
=QUERY('Staff List'!A2:E12, "SELECT A, B, C, E WHERE E = 'No'")
The query is referenced in another cell like this.
=QUERY('Staff List'!A2:E12,A1)
where A1 contains "SELECT A, B, C, E WHERE E = 'No'"
so instead of Editing A4 you can just edit A1 when needing to change the query.
My Question is this:
Can the same concept be applied to the date I wish to reference in a query?
For example can use something like this
=SORT(Query(A1,"Select * where Col7 >= DATE """&TEXT(A2,"yyyy-MM-dd")&""" AND Col7 <= DATE """&TEXT(B2,"yyyy-MM-dd")&""""),1,true)
where I insert {'1'!P5:V1000;'2'!P5:V1000;'3'!P5:V1000}
into cell A1
Instead of this:
=SORT(Query({'1'!P5:V1000;'2'!P5:V1000;'3'!P5:V1000},"Select * where Col7 >= DATE """&TEXT(A2,"yyyy-MM-dd")&""" AND Col7 <= DATE """&TEXT(B2,"yyyy-MM-dd")&""""),1,true)
So far i had tried this to no avail
=SORT(Query(""A1"","Select * where Col7 >= DATE """&TEXT(A2,"yyyy-MM-dd")&""" AND Col7 <= DATE """&TEXT(B2,"yyyy-MM-dd")&""""),1,true)
=QUERY(1st param, 2nd param, 3rd param)
1st param of query can be referenced only as non-arrayed range like:
=QUERY(INDIRECT(A1))
____
where A1 contains range A1:C
arrayed ranges like these are not allowed:
{A1:C; D1:F}
____
{INDIRECT(A1:C); INDIRECT(D1:F)}
as for the 2nd and 3rd QUERY param, those are allowed to be referenced as a string even if it contains a date atribute

How to reference two columns from two different sheets in one query

I'm trying to write a query that looks compares strings within a cell on two different pages. This is the query I have written but it says unable to parse query string because there is no column b4.
=QUERY(Teams!B:F, "select F where B = B4", 0)
Note column B is on a different page than B4.
if B4 is number do:
=QUERY(Teams!B:F, "select F where B = "&B4, 0)
if B4 is not number do:
=QUERY(Teams!B:F, "select F where B = '"&B4&"'", 0)

Improve Query Function in Google Sheets

I've been using the following function:
=query(Sheet1!A2:D," select A, B, C where A matches '"&JOIN("|", A2:A)&"' and D matches 'yes'")
Is there anyway that I can make is so that every row that starts with a match will be added a comma separated list in which each column occupies one cell with no duplicates as shown in sheet3.
https://docs.google.com/spreadsheets/d/1YDxIUnZzzYde9hcexPoDegv4HBuiUwk2wLKSXazu9hE/edit?usp=sharing
Sheet 2 has the function that I used and the result.
It is not entirely clear what you want to do, but try this. In Sheet1 in E2 put this combining Col A and D:
=arrayFormula(A2:A & if(isBlank(D2:D),""," ") & D2:D)
In F2 combine Col C and D with this:
=arrayFormula(B2:B & if(isBlank(C2:C),"",",") & C2:C)
In G2 find the unique values from Col F with this:
=UNIQUE(E2:E)
In H2 put this and drag the formula down:
=join(",",query(E2:F,"select F where E contains '"& G2 &"'"))
Hide Cols E & F

Resources