Column BY isn't pulling in google sheets query [duplicate] - google-sheets

This question already has an answer here:
Col BY causing parse error in Google sheets query
(1 answer)
Closed 5 months ago.
=query('Network Trade Data_2'!$AA$1:$CP,"Select AA, AC, BY where AC is not null",1)
I am just trying to pull in column BY but getting an error due to by also being a command. Any help would be greatly appreciated!

This is a known problem ."BY" is a reserved word in query strings since "by" is an actual syntax word you might use. The easiest fix is to change your range to an array and refer to things by their column numbers instead of range refs.
=query({'Network Trade Data_2'!$AA$1:$CP},"Select Col1, Col3, Col53 where Col3 is not null",1)

the other fix would be to use `:
=QUERY('Network Trade Data_2'!AA1:CP, "select AA,AC,`BY` where AC is not null", 1)

Related

Google Sheets - Using a sum formula and multiplying that sum depending on the status of checkboxes

I'm just starting and trying to learn about google sheets and I've got a much more involved sheet than what I'm showing here, but essentially I have ten check boxes and those boxes are each given a unique value when checked. When not checked they are all 0.
In this image I have 10 boxes in column A, with their assigned ON values in column B. Column C1 has the =SUM formula.
What I'm trying to figure out is how to multiply the summed number if boxes 9 OR 10 are selected. So box 9 and 10 would still contribute their value for the sum function but then would also have a multiple value that is triggered for the summed total.
Thanks in advance for any help!!
edit: sorry, I think I've caused some confusion. The values in the B column are just a visual representation of the value of the assigned value of the check boxes themselves, they aren't actually necessary to be used, but I'll see if I can use any of the answers listed to logic my way through it! thanks!
use:
=SUMPRODUCT(SUMIF(A1:A10, TRUE, B1:B10)*IF(A9=TRUE, B9, 1)*IF(A10=TRUE, B10, 1))
Try this
=ArrayFormula(IFERROR(SUM(QUERY(VLOOKUP(
QUERY(IF(A1:A<>TRUE,,ROW(A1:A)), "Select * Where Col1 is not null",0),
QUERY({ROW(A1:A),B1:B}, "Select * Where Col1 is not null") ,2,0), " Select * where Col1 is not null "))*
PRODUCT(QUERY(VLOOKUP(QUERY(IF(A1:A<>TRUE,,ROW(A1:A)), "Select * Where Col1 is not null",0),
QUERY({ROW(A1:A),B1:B}, "Select * Where Col1 is not null") ,2,0), " Select * where Col1 is not null ")),""))
Test all checkboxes

Query formula ignores string values [duplicate]

This question already has answers here:
Query is ignoring string (non numeric) value
(2 answers)
Closed 5 months ago.
I have a table that is a result of a few smaller tables merged together.
It's a result of searching a few sheets for rows that meet filtering criteria.
I wanted to remove empty rows using QUERY formula but it works in a strange way!
Normally
=QUERY(A1:Z,"Select *",0)
should return a full table. But not in this case.
What I actually try to do is to remove empty rows. I tried:
=QUERY({A1:Z},"Select * where Col5 is not null",0)
as column E is empty only when whole row is empty. But it does not work. It seems to ignore string values and sees only numbers.
Here is dummy table.
https://docs.google.com/spreadsheets/d/12QmFW9vlx4ToHsQYGmkXK4aLD2jlI30FV1wYgxa0V8c/copy
It looks like this:
When I apply Query that should cut empty rows, my result table looks like this:
It seems to cut all the rows without number value in Column A (strange!)
Note: Table is generated by a very long formula that searches multiple sheets. Whenever result is not found in one of sheets, formula returns empty row. So I need a solution to wrap around existing formula. Normally QUERY is a way to go, but not this time.
I know that I can make additional step. Make one more sheet and use Filter:
=filter(Sheet1!A1:Z,Sheet1!E:E<>"")
Anyway this solution adds bulk to my spreadsheet.
If you convert Col E to text (TO_TEXT), you can run the query without worrying about mixed data:
=index(query({Sheet1!A:D,to_text(Sheet1!E:E),Sheet1!F:Z}, "select * where Col5 is not null ",0))
QUERY only returns the predominant data type per column. Your E column has mixed data types (strings and numbers, with numbers being predominant), so anything that is not a number will be a null — and thus ruled out by the QUERY.
As for how to solve it, that would be difficult to impossible to do given your sample spreadsheet only, since we can't see the actual formula that generates the initial output shown in sample Sheet1.
there are ways but "short-formula lovers" will hate it... for example:
=ARRAYFORMULA(IF(ISNUMBER(QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)*1),
IFERROR(1/(1/QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)*1)),
QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)))
or:
=ARRAYFORMULA(IF(QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)<>"",
IF(ISNUMBER(QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)*1),
QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)*1,
QUERY(TO_TEXT(Sheet1!A:Z), "where Col5 is not null", 0)), ))
if you need zeros
or try like this:
=FILTER(Sheet1!A:Z, TRIM(FLATTEN(QUERY(TRANSPOSE(Sheet1!A:Z),,9^9)))<>"")
=FILTER(your_formula, TRIM(FLATTEN(QUERY(TRANSPOSE(your_formula),,9^9)))<>"")

Google sheets - getting percentages of yes, no, maybe responses into a pivot table

I have some data. One of the columns (Column D) has data such as "yes", "no", 'Credit", "n/a", "half".
At the top of that column, I have created a function which allows me to get percentage of "yes" responses, but not as a percentage of all responses, but just as a percentage of the responses that are "Yes", "No" and "Half"
Formula below
=iferror((COUNTIF(C3:C, "yes") / (COUNTIF(C3:C, "no") + COUNTIF(C3:C, "half") + COUNTIF(C3:C, "yes"))))
Below that, starting at row 3, is the data.
What I want to do is put data this into a pivot table. One of my other Columns is date, and I want to be able to group the data by month (actually by week, but I have already worked that out).
I am looking for my grand total value to be summarised using the formula above, which doesn't exist as one of the standard summary options.
I am interested to hear your ideas on the best way to solve this.
Thanks
Edit: here is a link to a sheet with the basics of what I am trying to do. Thanks for your help with this.
https://docs.google.com/spreadsheets/d/1ew4pPv4qtJCZJCaUgg_I7VdL5F00t-PFhIlg2bs8sh0/edit?usp=sharing
One "extended" solution is
get all yes per month in L3
=query({arrayformula(EOMONTH(B$3:B,0)),C3:C},"select Col1, count(Col2) where Col2='yes' group by Col1 label count(Col2) 'Exercice-yes' ")
get all yen/no/half per month in N3
=query({arrayformula(EOMONTH(B$3:B,0)),C3:C},"select Col1, count(Col2) where Col2='yes' or Col2='no' or Col2='half' group by Col1 label count(Col2) 'Exercice-yes|no|half' ")
get all unique monthes in G3
=arrayformula(unique(if(B3:B="","",eomonth(B3:B,0))))
and finally find the %
=arrayformula(iferror(VLOOKUP(G3:G,L:M,2,0)/VLOOKUP(G3:G,N:O,2,0)))

How to combine all the columns in into one and count them respectively in google sheet?

Data
Hi everyone,
I have 3 columns of data for the age of people in a city and also 3 columns of the count for the ages. I want to combine all the 6 columns into 2 columns which means there will be only one column of age data and one column for number of count. I try to use query function in googlesheet but not sure how to use it. Please give me some advice on this if there is other method that can achieve the same result. Thank you.
Try
=query({G8:H; J9:K; M9:N}, "Select Col1, sum(Col2) where Col1 is not null group by Col1 label sum(Col2) 'Count of people'", 1)
and see if that works?
and see if that works?

Google Sheets import range returning incorrect data

The full google spread sheet system is used for score keeping and is prone to delays when updating, however I have never run into an issue like this were the same basic function is returning two separate results. The problem is repeatable and occurs on more than one spreadsheet.
I have created a test sheet-
https://docs.google.com/spreadsheets/d/1arh0D9ch5MpQjRh_bHjLfLx5S7TAW8R_pgGLf5tovig/
with the code in question; Can anyone help please?
=QUERY(IMPORTRANGE("***","***"),"select Col1 where Col1 <>5 order by Col9 desc")
in your QUERY formula you are selecting cells that are numeric and comparing it to <>5 but take a notice that A2 is not numeric:
that is the reason why 2 2 is not included in your C column
also it looks like that your QUERY formula smashed first cells into one because you did not specify the 3td query parameter. try:
=QUERY(IMPORTRANGE("1pnowvo6YVj-DZAPCaKE2x9vSIbpAAmlwhRMO2OZNlrE","color!A84:M115"),
"select Col1 where Col1 <>5 order by Col9 desc", 0)

Resources