Filtering a query in Google Sheets - google-sheets

I am using QUERY in google sheets to import data from one tab to another in the sam sheet. However, I would like to filter the data please by a specific team - basically only selecting the cells in column F which have a value of "Team B" in their column B
Any idea how I would do this please?

Use a where clause, like this:
=query(Sheet2!A1:Z, "select F where B = 'Team B' ", 1)

You may find FILTER an easier option.
Suppose your source data sheet is named Sheet2. Try:
=FILTER(Sheet2!F2:F, Sheet2!B2:B="Team B")

Related

Google Sheets Error: column doesn't load when querying multiple sheets

I'm trying to query two separate sheets to a cell in my budget. One of the sheets is a google form I use to track my daily cash transactions, and the other is a ledger I'm using to input my bank transactions.
If I query either one of the sheets like this, either works fine:
=SUM(QUERY('Form Responses'!$A$1:$C$400,"SELECT B,C WHERE B = 'Coffee'",1))/$D$1
=SUM(QUERY(Ledger!$A$1:$C$400,"SELECT B,C WHERE B = 'Coffee'",1))/$D$1
HOWEVER, when I try to combine them like this...
=SUM(QUERY({'Form Responses'!$A$1:$C$400;Ledger!$A$1:$C$400},"SELECT B,C WHERE B = 'Coffee'",1))/$D$1
I get this error:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: B
I have gone deep into forums and SO, and have found lots of tips - but none of them work and many of them are depreciated. Can anyone solve this issue at a glance?
I don't understand how there can be a 'Column B' when they're queried individually, but not when queried together.
use:
=SUM(QUERY({'Form Responses'!$A$1:$C$400; Ledger!$A$1:$C$400},
"select Col2,Col3 where Col2 = 'Coffee'", 1))/$D$1

Can you create a dropdown in Google sheets using a vlookup?

I have a sheet that looks similar to this:
Is it possible to create a formula in column B that will create a dropdown with the options from columns D through F and reference the selection in column A to find the values? Thank you!
Understood.
Use a helper column and add the following formula:
=IFERROR(TRANSPOSE(query(C1:F3,"SELECT D,E,F WHERE C = '"&A1&"'")),"")
Then at B1, select "List from a range" in data validation dialog and enter the following in criteria:
=$I$2:$I$14
Link to example: https://docs.google.com/spreadsheets/d/1qAd7WFUjkMBTgxheoLRjG_RHXBplwg_qMSmXAbOsC1s/edit?usp=sharing
-Prior answer-
I would use a helper column.
B1: =TRANSPOSE({C3:F3,C4:F4,C5:F5})
Then simply reference B1:B.

Google sheet complex query?

Hello I need help with named range in google sheet...
=QUERY(Data,"SELECT C,D,E,SUM(G),L,SUM(G*M) WHERE A = '"&$A$1&"' AND E = '"&$B$1&"' GROUP BY C,D,E,L",1)
I'd like to calculate columnG*columnM and than SUM this results when grouping.
This works fine before I start grouping table. I could do columnG*columnM get result and use another QUERY but don't like the idea of using many helpers. Is it even possible?
Could you provide a link to your project ? I make a simplified example : if you need the sum of ColumnB x ColumnC, you have to add to your data an extra column as following
=query({A2:C,arrayformula(B2:B*C2:C)},"select SUM(Col4) group by Col1 ")
and then usie ColX instead of A,B,C and the extra column D.

How to create multiple columns using data from the filter function in Google Sheets

I just started using google sheets to help edit tables for a database and I need some help creating a function. In ColumnA, I've got a list of MovieID's, in ColumnB, there is a list of directors, and in ColumnC, there is a list of unique directors from ColumnB. I'm trying to filter the data and create a set of columns where in one, there is the director's name and in the other, there's the movieID that corresponds to a film the director was involved in.
Ive created a function in F2 to find the ids for a director, and I can just drag the formula down (when the data is transposed, and the C2 value will shift to C3, C4....) But, I want the name of the director to be included in the column to the left of the filtered results (like I've manually done in E), but I can't really figure it out, and I'm not entirely sure on how to use the other functions to get it right.
Any help or guidance on how to achieve this would be greatly appreciated!!
Looks like this will solve your issue
=INDEX(QUERY(SPLIT(FLATTEN(
SPLIT(B2:B,", ",0)&"#"&A2:A),"#"),
" where Col2 is not null order by Col1 "))
If on the other hand there is only one name in cell E2 use
=QUERY(ArrayFormula(IFERROR(SPLIT(IF(REGEXMATCH(B2:B,E2),C2&"-"&A2:A,),"-"))),
"where Col1 is not null",0)

Google Sheets - Query - Concatenate text to returned data

In Google Sheets, I would like to add an Hyperlink to the output data. Something like:
HYPERLINK("https://www.google.ca/search?q="&QUERY_RESULT, QUERY_RESULT)
So I would have a column of one or more results that would be an Hyperlink.
If it can help, my query look like that:
=QUERY(A:K; "select B where I contains 'Done' ORDER BY B ASC LABEL B 'Results'"; 4)
I think I could use a CONCAT function, but I am not sure how I would write this down in a GSheets Query. Any help is appreciated!
QUERY produces a array. You need to explicitly mention that your formula is a ARRAYFORMULA:
=ARRAYFORMULA(HYPERLINK("https://www.google.ca/search?q="&QUERY_RESULT, QUERY_RESULT))

Resources