Query information not populating in Google Sheets - google-sheets

Here is a link to the doc
On sheet two cell A6 there is a query:
=QUERY('Events Summary'!1:970, "SELECT A,F,BG,M,BA,BB,BC,BD,BF,BE
WHERE F = date'"&text(Today(),"YYYY-MM-dd")&"'order by M DESC ",1)
The information for columns A, F, & M populates but the rest do not. Is this because they are out of their natural order?

it is empty because the source is empty:

Related

How to prevent duplicates between two different sheets on google sheets?

I have 2 sheets, one is sheet1, other is sheet2.
Data in sheet1
Name
A
B
C
D
E
L
M
N
O
P
Data in sheet2
Name
F
G
D
H
G
Here in sheet2, two data is duplicated. One is "D" compared to sheet1, other is "G" in same sheet2.
I want to prevent duplication in both these cases so that whenever I enter new value in sheet 2, it must check both the sheets and reject duplicate entries.
I am using Google Sheet, and using data validation with a custom formula =COUNTIF(sheet1!A2:A&sheet2!A2:A,Sheet2!A2)<2
But, it's not working. Please help me.
Try with:
=COUNTIF({sheet1!$A2:$A;sheet2!$A$2:$A},Sheet2!A2)>1
With curly brackets you can join the ranges

Google Sheets Query: Multiple Values in a Single Cell Reference, is it possible?

Good morning!
I want to ask if it is possible that the cell reference for "houses" on "worksheet!C3" return values for A&B only or A&C only or B&C only while only using one cell ("worksheet!C3") as cell reference, or is there a better approach on trying to return the values?
formula I'm using:
sum(query(Encoding!$A$4:$K$9,"Select D where (A contains '"&C$2&"') and (B contains '"&C$3&"') and (C = date '"&text($B$4,"yyyy-mm-dd")&"')"))
Sample data is attached,
https://docs.google.com/spreadsheets/d/1sY6YQRQ6Im-zTdzf0u31rphnQR0eL_YzDahpgMQ7E1Y/edit#gid=37782805
Try, as far as I understood the subject correctly
=sum(query(Encoding!$A$4:$K$9,"Select D where (A contains '"&C$2&"') and (B contains '"&C$3&"' or B contains '"&C$4&"') and (C = date '"&text($B$4,"yyyy-mm-dd")&"')"))
you can also put one formula in A5 as follows
=sort(query(arrayformula(split(flatten(Encoding!A4:A9&"~"&Encoding!B4:B9&"~"&Encoding!C4:C9&"~"&Encoding!D3:K3&"~"&Encoding!D4:K9),"~",true)),
"select Col4,sum(Col5) where Col3="&B4&" and (Col2 contains '"&C$3&"' or Col2 contains '"&C$4&"') and Col1="&C2&" group by Col4 label sum(Col5) ''"),1,0)

Using QUERY with IMPORTRANGE

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.

Trying to include additional columns in QUERY result on GoogleSheets

I'm using Google Sheets and using the following formula without any issue:
=QUERY(Sheet!A:D,"select A, max(B) where not B is null group by A label A 'Client', max(B) 'Most Recent'")
Obviously, this is returning columns A and B of the referenced data
However, I would like to also return the corresponding cells from column C.
sample data: https://docs.google.com/spreadsheets/d/1CJKiDNPUWMMUbLLb-UDA6iRA2PBnlMHDsEB9vELe0Rk/edit?usp=sharing
Using this example, what I would like to see is cell G2 populated with "Pizza" (i.e., from C3), and so on.
Am I using the right formula? What do I need to change?
What you are trying to do is not very SQL-like, because max(B) does not point to any particular row: it's just the maximum value of B among the selected rows. This value could be attained by several rows, making the choice of C, D ambiguous. I don't think that a single query can do this.
Here is an implementation with unique and several query commands.
In E2, enter =unique(A:A) to get the list of unique client names.
In F2, enter
=query(A:D, "select B,C,D where A ='"&E2&"' order by B desc limit 1")
and drag this formula down. This selects all rows with the A value matching E2, and picks one with maximal B value.
You don't want to have a header row in the output of these queries so either add label B '', C '', D '' or just don't include the header row in the queried range.
Version with grouping by C,D
To also select C and D within a single query, expand the select clause
select A, max(B), C, D
which will then require including those in the group by clause:
group by A, C, D
The formula will be
=QUERY(A:D,"select A, max(B), C, D where not B is null group by A, C, D label A 'Client', max(B) 'Most Recent'")
This does mean that the only rows to be grouped together will be those where not only A but also C and D are equal.
A possible one-formula solution:
=ArrayFormula(IFERROR(VLOOKUP(UNIQUE(A2:A),SORT(A2:C,2,0),{1,2,3},0)))
Here is what I did that finally worked.
In E1, enter =unique(A:A) to get the list of unique client names. In F2, enter
=query(A$2:D101, "select B,C,D where A ='"&F2&"' order by B desc limit 1")
and drag this formula down. This selects all rows with the A value matching E2, and picks one with maximal B value.
You don't want to have a header row in the output of these queries so just add desired text in header row.

How do I reference a non-consecutive range of columns in Google Sheets?

I am attempting to draw responses from a Google Form and filter the responses onto another sheet. However, I want to select a non-consecutive range of columns. For example, I am attempting to paste the results of Columns A through B, M through V, and X on the sheet titled 'Form Responses 1' dependent on matching the value of B1 on the current sheet to the value in the B column of 'Form Responses 1'.
'Form Responses 1' Google Sheet
I am attempting to execute the following code but it doesn't work.
query(INDIRECT('Form Responses 1'!A2:B'Form Responses 1'!M:V'Form Responses 1'!X),"Select * Where B = """&B1&""" ")
The issue is with the first parameter of the query since
query('Form Responses 1'!A2:L,"Select * Where B = """&B1&""" ")
works as I want it to, pasting columns A through L dependent on matching the value of B1 on the current sheet to the value in the B column of 'Form Responses 1'.
Do you have any suggestions?
Thank you.
Does this formula work as you want:
=QUERY({'Form Responses 1'!A2:B,'Form Responses 1'!M2:V,'Form Responses 1'!X2:X},"where Col2 = '"&B1&"'")

Resources