I have a named range in Google Sheets and I am making a simple query which should return a value but it doesn't work:
=QUERY(range2,"SELECT B WHERE A contains 'test' ")
It should return "2" but it sais that the query completed with an empty output.
Is it a bug?
actually, QUERY is known to behave like this and its caused by a superiority of numeric values over text string values in a given dataset. fix would be to select columns A and B and format them as Plain text
another approach would be to convert dataset within formula like:
=ARRAYFORMULA(QUERY(TO_TEXT(A:B),
"SELECT Col2
WHERE Col1 contains 'test'"))
Related
I need to know if this is possible:
I have a data in Google Sheets. I want to do a query on the data itself.
I want to be able to query any data that has a certain cell filled in with a date format. If the cell is filled in with a date format, then the data is transferred over to the query but if it does not contains date data in the cell, then the data won't get queried over.
So Is it possible to put a nested if statement in Query?
For example this is the workflow of the query
Check if Date cell is filled with data >> Check for the Broker name >> Select Column B and F to show in the query
Below is my Query formula so far:
=QUERY({Funded_2022!A:AM, if(Not(IsBlank(W:W)))}, "Select B, F")
and its coming with the error message:
Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 2002. Actual: 1
try:
=QUERY({Funded_2022!B:B, Funded_2022!F:F, Funded_2022!W:W},
"select Col1,Col2 where Col3 is not null", )
I'm trying to solve why one of the Google Sheets I maintain is failing to operate properly. I've isolated that the issue is with a query
QUERY(Import_MJL!A:BU, "select A where AJ> 0")
For reference the Import_MJL sheet is a static database. The AJ column holds a currency value. When performing an IF function of that column, it returns as TRUE as seen here
if(Import_MJL!AJ2 > 0,1,0)
What could be the reason that the query is not recognizing when my AJ Column is above 0 ?
Screenshot for bellow reference. Row 1 holds the code & row 2 holds the Results (The B2 Cell should result in an array whose length is over 10K but only returns the header. The Import_MJL!AJ2 cell has value 38K and should be a result of the cell on B2)
Screenshot of code and results
Thanks for the time y'all!
Chances are that Import_MJL!AJ2 does not contain a number but the text string $38,738.00 that only looks like a number. Many spreadsheet functions will automatically convert such values into numbers, but query() will not.
You can check whether a value is actually a number with the isnumber() function.
Here's a quick fix to try:
=arrayformula(
query(
{ Import_MJL!A1:AI, value(Import_MJL!AJ1:AJ), Import_MJL!AK1:BU },
"select Col1 where Col36 > 0",
1
)
)
I have a simple sheet to try to track and format race results from a league that I've joined. For the most part I know how I want to do this but when I use a query it's dropping data in some situations and formatting it strangely in others.
It seems as if where there are more numbers in a column than text it drops all text entries.
In addition for some reason when I add a check row, if it's included in the query it pushes almost all the data into a single cell except for the check row.
Would someone mind having a look and trying to figure out why it's doing this. Link Below
On sheet RRL1 I have my compiled data on the left, my 'missing' data on the right and my weirdly formatted data below.
https://docs.google.com/spreadsheets/d/1c9xlQG06dQCrpMk3UMAX29oTlpRuhTfx6btbYTGmC8g/edit?usp=sharing
The query() formula will only support one data type per column — number, text, boolean or date. The type is determined by the majority of the values in the first few hundred rows. Values that are of another type will be returned as null, i.e., blank values.
=QUERY('Tournament Details'!D2:E22)
Use an { array expression } like this:
={ 'Tournament Details'!D2:E22 }
=TRANSPOSE(query('Tournament Details'!I3:I26))
Use this:
=transpose('Tournament Details'!I3:I26)
Use this pattern to replace "DNS" and "DNF" with nulls:
=arrayformula(
query(
{ 'RRL1'!A1:C, iferror(value('RRL1'!D1:D)) },
"select Col3, sum(Col4)
where Col3 is not null
group by Col3
label sum(Col4) 'Total AUS RRL1' ",
1
)
)
The "squished" values you mention come about because you are not specifying the headers parameter. The best practice is to always include it, like this:
=query('Tournament Details'!A2:E22,"select A where C != 'N/A'", 1)
In my Google spreadsheet, i'm using the query function to get data from one sheet onto another. The query looks something like this:
=QUERY('mySheet'!$A$1:100,"select F where "&C$3&"='myValue'")
This works fine until cell C3 has value "BY" (because the word "by" has significance in the query language). I've tried using single quotes, but then the query uses header "BY" instead of column BY and it returns an empty result.
Any ideas on how to work around this?
Put it in backticks.
=sum(QUERY(select `BY` where `BY` is not null limit 7))
This will sum the first 7 values in column BY.
(This was fun to debug. The formula worked in every other column...)
"BY" is a special word. It is present in clause group by
You may use this:
=QUERY({'mySheet'!$A$1:100},"select Col5 where Col"&C$3&"='myValue'", 0)
and paste the column number into C$3
see more info here
BTW you may use function column() to know BY is column 77 or find the right number by header name: =match("column name", 'mySheet'!1:1, 0)
I am trying to conditionally format a row in Google Sheets based on the result of a QUERY operation. I can get the QUERY to return the value I want (either 0 or non-zero), however QUERY insists on returning a header row.
Since the QUERY now takes up 2 rows for every row of data, changing the format of the row based off the QUERY result starts to get weird after just a few rows.
The problem I am ultimately trying to solve in the case where I enter a list of names, and I want to compare each name to a list of "NSF Names". If a name is entered, and it exists on the NSF list, I would like to flag the entry by highlighting the row red.
Help is greatly appreciated.
Edit: Formula, as requested:
=query(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"'")
A:D is the data set (A is a numeric ID, B is full name, C and D are first and last names respectively).
E1 and E2 are placeholders for the person's first and last name, but would eventually be replaced with parsing the person's name, as it's inputted on the sheet (TRIM(LEFT(" ", A2) etc...)
I can get the QUERY to return the value I want (either 0 or non-zero),
however QUERY insists on returning a header row.
There might be better ways to achieve what you want to do, but in answer to this quote:
=QUERY(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"' label count(A) ''")
A query seems a long-winded approach (=countifs(C1:C7,E$1,D1:D7,E$2) might be adequate) but the label might be trimmed off it by wrapping the query in:
index(...,2)