I want to pass in ARRAYFORMULA into the QUERY so that I can get the sum without splitting the two functions apart.
I want to do this but getting an error ("unable to parse query string for function query parameter"):
=QUERY(ARRAYFORMULA(SPLIT(O5:O7, " to ")),"select sum(O),sum(P)")
Example:
This is the input:
1.080 to 3.240
0.771 to 2.312
0.721 to 2.164
Above input is pass in as O5:O7. Using this function, it will split into 2 columns and extract the number:
=ARRAYFORMULA(SPLIT(O5:O7, " to ")
As result, shown as following:
1.08 3.24
0.771 2.312
0.721 2.164
The above result will be pass into as O18:P20. This function will give the sum of each columns:
=QUERY(O18:P20,"select sum(O),sum(P)")
Result as the following:
sum sum
2.572 7.716
Could I pass in the arrayformula's result into the query?
Use BYCOL() lambda function after splitting. Try-
=BYCOL(INDEX(SPLIT(P5:P7," to ")),LAMBDA(x,SUM(x)))
Or QUERY() function like-
=QUERY(INDEX(SPLIT(P5:P7," to ")),"select sum(Col1),sum(Col2)")
yes:
=ARRAYFORMULA(QUERY(SPLIT(O5:O7, " to "), "select sum(Col1),sum(Col2)"))
if you dont need labels:
=INDEX(QUERY(SPLIT(O5:O7, " to "), "select sum(Col1),sum(Col2)"), 2)
Related
I'm new to google sheet. I have a column(E) with the date and another with a session(F), I want to merge them into one column with each date & different session just like the first few rows in column C.
I've tried "=ArrayFormula(concat(D2:D,concat(" ",F2:F5)))" in column C but only got the first date.
use:
=INDEX(QUERY(FLATTEN(FILTER(E2:E, E2:E<>"")&" "&
TRANSPOSE(FILTER(F2:F, F2:F<>""))), "where not Col1 starts with ' '", ))
see: https://stackoverflow.com/a/68775825/5632629
In your cell C1, try this formula:
=ArrayFormula(E1:E&" "&F1:F)
Well you can simply do concatenate cells like this:
CONCATENATE(E1, " ", F1)
to get what you want I think.
What you're looking for is a cartesian product. I don't have a single formula that does the entire thing for you, but I can suggest a two-step approach.
Get the cartesian product with this formula:
=ARRAYFORMULA(SPLIT(FLATTEN(E2:E9 & "|" & TRANSPOSE(F2:F5)), "|"))
This gives a pair of each date against each time in two result columns. You can then concatenate each row of them in a final result column.
Using Google Sheets:
Here is my current formula that I am using to return the data from ONE Date and I am looking to duplicate this formula except SUM the data of a Date Range.
Current Formula:
=IFERROR(INDEX('Delavan Ford'!$AJ$3:$AJ$1000, MATCH ($B$1,'Delavan Ford'!$V$3:$V$1000,0)),"")
B1= the current single date field that it is looking for a match for and returning the data.
I would be adding another field in B2 to be the second date that it is looking for to return the sum of the data between the 2 dates.
Thanks.
SumIF or SumIFs should work. Personally I prefer to use the QUERY() function as I feel it is more intuitive.
You can use SUMIFS() like-
=SUMIFS(A3:A,V3:V,">="&B1,V3:V,"<="&B2)
Or QUERY() function like-
=QUERY(A3:V,"select sum(A)
where V>= date '" & TEXT(B1,"yyyy-mm-dd") &
"' and V<= date '" & TEXT(B2,"yyyy-mm-dd") &
"' label sum(A) ''")
I am trying to use the Google Sheets QUERY function, and I have two sheets, and am trying to query a range in one sheet using a value from another sheet.
Here is the query:
=query(EntireLI, "Select * where D is not null and D CONTAINS "&C43&"", false)
I also tried LIKE instead of CONTAINS.
The error I am getting is:
Error: Unable to parse query string for Function QUERY parameter 2: NO_COLUMN:
Discord
When I change "&C43&" to 'Discord', then the function works, but I want it to grab this value dynamically, rather than hardcoding it.
I do not understand why it is using the value of the cell as the name of the column.
The broken query:
The sheet I am querying:
use:
=QUERY(EntireLI, "where D is not null and D contains '"&C43&"'", 0)
I have this Google Sheet with a query formula in it. I am trying to use the query to display an average 1-5 satisfaction rating for each program. This script I adapted from Info Inspired - see "formula 1" - is basically working using the following formula in cell A2:
=query(ArrayFormula('Form Responses 1'!B2:E),"Select B,Avg (E) group by B label Avg(E)''")
However, this is displaying the results ordered alphabetically by program.
How can I order the output by the average rating currently in column B of the image?
I tried using the order by clause as in:
=query(ArrayFormula('Form Responses 1'!B2:F),"Select B,Avg (F) group by B label Avg(F)'' order by Avg(F)")
and
=query(ArrayFormula('Form Responses 1'!B2:F),"Select B,Avg (F) group by B label Avg(F) order by Avg(F)''")
but both gave me:
Error Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " "order" "order "" at line 1, column 44. Was expecting one of: "format" ... "options" ... "," ...
I am not sure what the '' is doing, but the first query mentioned only works with it in there.
try it like this:
=QUERY(QUERY(ARRAYFORMULA('Form Responses 1'!B2:E),
"select B,Avg(E) group by B label Avg(E)''", 0), "order by Col2 asc", 0)
'' is literally nothing eg. empty label
I'm using FILTER to extract rows from a range, and want to take only certain columns. For example, I filter by D, but want only columns B,C in reverse order. I tried to use QUERY:
=QUERY(filter(B:D,D:D>=2), "select C,B") - Error: can't analyze query string for function QUERY parameter 2: NO_COLUMNC
=QUERY(filter(B:D,D:D>=2), "select *") - shows me all columns, so QUERY should work...
How do I QUERY the results of FILTER? Any other way to achieve this?
When you are QUERYing a computed array, you need to use the Colx notation rather than column letters:
=QUERY(FILTER(B:D,D:D>=2),"select Col2, Col1")
which incidentally can be achieved by just using the QUERY:
=QUERY(B:D,"select C, B where D >= 2")
or just FILTER:
=FILTER({C:C,B:B},D:D>=2)
Although using the Query function is simple and straight-forward. There's another way to achieve this output using the Filter function
You can nest the original FILTER function inside another FILTER function and specify an array of 1's and 0's mentioning which column you need and which you don't.
=Filter( FILTER(B2:E6,D2:D6>10900) , {1,0,0,1} )
How about using arrays on the go?
=FILTER({B:B, D:D},D:D>=2)
In this way you select columns in place, and they won't change if new column would be added.