Query based on cell reference on multiple conditions on Google Sheets - google-sheets

I am trying to create a search function where users are able to select from a list in Google Sheets and the below query function will return that data that corresponds from the users' selections.
=query(Overview!A:AF,"SELECT D,I,M,AA WHERE AA = '"B27"' AND L ">=" "&E27&" AND S CONTAINS '"&H27&"'",1)
I expected to get the list (D, I, M, AA) but I keep getting #ERROR, what is the problem?

this is the correct syntax:
=QUERY(Overview!A:AF; "SELECT D,I,M,AA
WHERE AA = '"&B27&"'
AND L >= '"&E27&"'
AND S CONTAINS '"&H27&"'"; 1)

Related

Filter values that are on a range of rows on google sheet

I'm trying to filter couple of codes on google sheets but it is a range of values.
On the colum original are all the codes that I've it and I want to create a new column with the codes on the filter column out of it.
I was trying to use the function filter [filter(A2:A,A2:A<>B2:B)] but as is a range of values, it only takes the first line. I also tried with query, but I've the same issue.
original filter
Bgk3lUxIRbQ SCjsMoiTv-U
8_yFDcYSbdk RvrH8d-2QC0
video ID L0 vjPEWgAHYn8
TRCAP3URkI0 jWBhOP-hSQo
6iVi8wjA3Ko b2VRWJkNM6g
SBgP0xQCxEM EI7NkW6aF74
qV_i6-NijsE Ls7M5PxM8cc
hQMURWV1EBQ ZY-BR-CZPIs
vrNekZVjQ38
9pjx7n_sIm4
owJQQlp8KLA
Bgk3lUxIRbQ
8_yFDcYSbdk
kPpNi6SHYMk
kqKPXS9wVA4
QUYx8m8HqJA
TkqQbtKuinI
SCjsMoiTv-U
video ID L0
video ID L0
wAsBZ36kDd0
8NS9d806Q8Q
RvrH8d-2QC0
vjPEWgAHYn8
jWBhOP-hSQo
video ID L0
qV_i6-NijsE
hQMURWV1EBQ
TkqQbtKuinI
rhspLssYqug
vjPEWgAHYn8
video ID L0
PHM_q0fqaHo
kqKPXS9wVA4
e5DrB2rz170
b2VRWJkNM6g
EI7NkW6aF74
jWBhOP-hSQo
video ID L0
9pjx7n_sIm4
Bgk3lUxIRbQ
VCfm6jxxfd0
RTlVXL9iyy4
3hxupZ96_iM
Ls7M5PxM8cc
EI7NkW6aF74
ZY-BR-CZPIs
Custom Function Solution:
One way of doing this would be to create a custom function for Google Sheets.
Creating the Formula:
From the Tools > Script editor menu item, you can create a function with the following code:
function LISTFILTER(rangeToFilter, itemsToFilter) {
rangeToFilter = rangeToFilter.flat();
itemsToFilter = itemsToFilter.flat();
var filteredList = [];
rangeToFilter.forEach(function(item) {
if (!itemsToFilter.includes(item)) {
filteredList.push(item);
}
});
return filteredList;
}
Save the script with the save icon, and close the script tab.
Using the Function:
In a cell, you can call this function as follows:
=LISTFILTER(RangeToFilter, ListOfItemsToFilter)
For example, if you want to filter all the items in column B out of column A, you could write:
=LISTFILTER(A2:A,B2:B)
Which, for your example, will yield the following output:
Here, column C is filled with all the data in column A that is not also in column B.
References:
Custom Functions in Google Sheets | Apps Script | Google Developers

Google Sheets Query with Logic Statements

I am trying to create a list of data from a data range in Google Sheets. I thought of using the query function, but with that, you can't seem to use regular logical statements.
I know that this snippet of code is wrong and doesn't work, but hopefully it makes it clear what I'm trying to do.
=Query(E2:E103, OR(AND(D2:D103=A$2,G2:G103=A$5),AND(D2:D103=A$3,G2:G103=A$5),D2:D103=A$1))
In this code, A$2, A$5, A$3, and A$1 are all just string variables in the corresponding cells that tell the logic statement what to compare.
If there is another way to write this or a different function that accomplishes what I would like to do, it would be greatly appreciated if you could share it with me.
Basic case
The basic syntax for building a query logic:
"where F = '" & A1 & "'"
assumes A1 is a string, values in column F are strings
adds single quotes, makes the resulting query string: where F = 'sample text'
Logic
Your case looks like this:
where (A) or (B) or C =>
where (A1 and A2) or (B1 and B2) or C =>
where (D = 'text1' and G = 'text2') or (D = 'text3' and G = 'text4') or D = 'text5'

Reference column based on multiple cell values in Google Query

I'm trying to return a value in a column based on two cell references.
My current query is:
=QUERY(A:T,"select A WHERE P = '"&S200&"' AND Q = '"&T200&"'")
Column A is a number, P is a string, and Q is a number.
S and T correspond to P and Q, respectively.
All it's returning is column headers. What am I doing wrong?
Try this, Note the different quotes for the cell number reference.
=QUERY(A:T,"select A WHERE P = '"&S200&"' AND Q="&T200&"")

Google Spreadsheet Query return string from cell for 'contains'

I have a big table containing data about a volleyball tournament. Every game is listed with date, players and result.
I created a drop down list, containing all player names. By selecting the name the stats of each player are shown, like how many wins and losses.
Now I also want to list all games this player has played. To do this I found the QUERY function. I use it like this:
=QUERY(A4:G; "select * where (B contains '<name>') or (C contains '<name>') or (D contains '<name>') or (E contains '<name>')")
Now I want to replace <name> with the playername selected in the drop down list (which in my case would be cell AS24).
How can I do this?
This is my table:
Table
Thanks in advance!
Dambe
Try this:
=QUERY(A4:G; "select * where B="""&AS24&""" or C="""&AS24&""" or D="""&AS24&""" or E="""&AS24&"""")
Is it AS24 or AS4?
I just tried this and it works:
=QUERY(A4:G; "select * where B="""&AS4&""" or C="""&AS4&""" or D="""&AS4&""" or E="""&AS4&"""")

Google Spreadsheets: match multiple variables in multiple columns using match

Google Spreadsheets: I am trying to match multiple variables in multiple columns
I have tried this code
=match(T7&C7&"v";T$2:T6&C$2:C6&K$2:K6)
that I expected would woork, but it does not .... any ideas how I can do this?
Try this:
=ARRAYFORMULA(match(T7&C7&"v",ARRAYFORMULA(TRANSPOSE(Split(CONCATENATE(T$2:T6&C$2:C6&K$2:K6&"|"),"|"))),0))
If this does not work, please give us an example of your data
This is the final formula
=if(D2<>""; vlookup(arrayformula(MAX(( T$1:T1 = T2 )*4 + ( C$1:C1 = C2 )*2 + ( K$1:K1 = "✓" )*1));Lookup!D:E;2);"")
First check if cell empty
Then find mathcing values above the current row, start with most
important first
Then verify/code-label the results (7 = full match, 6 = site +
link, 4 = only site)
Setup a lookup table to translate the results to values you
understand

Resources