I'm making an analytic sheet in Google Spreadsheets and am using the QUERY function bundled in an INDEX function. However, I'm encountering a weird error. Sometimes, when the query returns no response, it gives a #REF error, reading "Function INDEX parameter 2 value is 2. Valid values are between 0 and 1 inclusive." This makes sense to me, since there's nothing being returned. However, there are also some times that I don't get an error, and the function returns just a blank cell.
When I remove the INDEX portion of the function, both times (error and blank cell) read the same thing, which is just "sum FEE", ie the operation and column title. I'm also using IMPORTRANGE so the data portion of the query function is a little tricky, but just know that it's calling a variable name of the original spreadsheet.
Here are the functions from both error response and blank response.
Error: =index(QUERY(IMPORTRANGE(Ranges!$B$1,"'"&$A6&"'"&"!"&"A:O"), "Select sum(Col8) where Col3=''",1),2,0)
Blank: =index(QUERY(IMPORTRANGE(Ranges!$B$1,"'"&$A7&"'"&"!"&"A:O"), "Select sum(Col8) where Col3 is null",1),2,0)
try:
=IFERROR(INDEX(QUERY(IMPORTRANGE(Ranges!$B$1,"'"&$A6&"'"&"!"&"A:O"),
"select sum(Col8) where Col3=''", 1), 2, 0))
Related
I have this Google Sheet file using this formula to split and flatten the input in B2:B3
=ArrayFormula(LAMBDA(sp, FLATTEN(SPLIT(sp, "♥"))))(BYROW(A2:A3, LAMBDA(rp, REPT(B2:B3&"♥",rp))))
I encounterd this error
Error
Invalid call to non-function.
What is it and How to solve it?
The error that you have received will mean that the formula was not able to call the parameter that your function was expecting, checking both of the 2 formulas that you have made:
LAMBDA(sp, FLATTEN(SPLIT(sp, "♥")))
And
LAMBDA(rp, REPT(B2:B3&"♥",rp))
Both of them are calling a range being this part of the formula expression however there is no really a valid value to be passed to the expression so it can "call it" to provide the result.
In a nutshell, the error "Invalid call to a non function" means that in your formula you have put the call parentheses "()" which contains the data that will be called to the function that you have named but this data can't be called.
An example of this error can be made with the following LAMBDA formula:
=LAMBDA(test, test())(A1)
Using this formula will display the same exact error and this is due to the parameter being "called" it's invalid, this is due to the data being called a range and not a valid function.
You can try this formula for lambda approach.
=LAMBDA(Rpt,Rpn,QUERY(INDEX(FLATTEN(SPLIT(REPT(Rpt&"♥",Rpn),"♥"))),"where Col1 is not null"))(B2:B3,A2:A3)
Without lambda-
=QUERY(INDEX(FLATTEN(SPLIT(REPT(B2:B3&"♥",A2:A3),"♥"))),"where Col1 is not null")
I think the issue is that you are calling a vertical range B2:B3 from within the internal LAMBDA that is not defined as part of the range to be passed to it from the BYROW that is calling it. I think a MAP would be more appropriate than the BYROW in this case as you can then feed multiple ranges into the LAMBDA it calls:
=arrayformula(lambda(flt,filter(flt,flt<>""))(lambda(sp,flatten(split(sp,"|")))(map(A2:A3,B2:B3,lambda(a,b,rept(b&"|",a))))))
N.B. - The additional outer lambda is required to filter out the empty cells that will occur when sp is flattened if the numbers of repeats in B2:B3 is not the same (as jagged arrays aren't allowed). This could obviously also be done with a QUERY, but here is one way of doing it with LAMBDAs all the way through.
Example file:
https://docs.google.com/spreadsheets/d/1M-o8Mu3vBrBgs1wC1WL5kqK61m6Vu1K5ylGByKDCZTo/edit?usp=sharing
On the sheet "To be coached" I have a query in cell A2. The query might not be optimal and maybe it's convoluted, but it works, aside from one small detail that I just can't get to work. This is the current query.
=QUERY({
IFERROR(QUERY(FILTER(ARRAYFORMULA({MATCH('Quiz results'!F9:F,Team!G2:G,0),'Quiz results'!A9:A,'Quiz results'!C9:C,'Quiz results'!D9:D,IFERROR('Quiz results'!A9:A/0),"Question:"&CHAR(10)&'Quiz results'!G8&CHAR(10)&CHAR(10)&"Provided answer:"&CHAR(10)&'Quiz results'!G9:G&CHAR(10)&CHAR(10)&"Correct answer:"&CHAR(10)&'Quiz results'!G7}),'Quiz results'!G9:G<>'Quiz results'!G$7),"SELECT Col1,Col2,Col3,Col4,'Quiz',Col5,'"&'Quiz results'!B6&"','"&'Quiz results'!G6&"',Col6 WHERE Col2 IS NOT NULL LABEL 'Quiz' '','"&'Quiz results'!B6&"' '','"&'Quiz results'!G6&"' ''"),{"","","","","","","",""})
},"SELECT * WHERE Col1 IS NOT NULL ORDER BY Col2,Col1")
Column B shows names, which for the sake of the example I have obfuscated into "Person 1" and so on. The result I'm trying to achieve is that column A shows whether the person mentioned in column B has an active status or not. That information is present on the sheet "Team" in column A.
So far, I've been able to get the query to present the row number of an array based on information from the sheet "Team" which contains the status of the relevant person. To do this I used a MATCH statement.
MATCH('Quiz results'!F9:F,Team!G2:G,0)
The problem occurs when I try to get the actual "Yes" and "No" values from the "Team" sheet by combining the MATCH statement with an INDEX statement.
INDEX(Team!A2:A,MATCH('Quiz results'!F9:F,Team!G2:G,0),1)
When I do this, the entire query fails with the message "Query completed with an empty output". This is probably due to the IFERROR statement. When I remove that, the error is as follows.
Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 1.
Actual: 998.
From what I can gather, this means that the INDEX+MATCH statement is providing 998 rows while the expected input for the query is only 1 row. But I don't understand why it is returning so many rows. When I use the same INDEX+MATCH statement on the sheet "Test" in cell A2, it returns only one cell as a result, giving "Yes". (That should actually give a "No" for the particular person on that row, but that is a different problem which might just be occurring due to using the statement in a different context.) Even when I encapsulate the formula in an ARRAYFORMULA, I still only get 1 cell as a result. So why is the same formula giving 998 rows when it's used in the query?
I am open to any and all ideas on how to get column A on sheet "To be coached" to show the correct "Yes" and "No" values for each person based on their status in sheet "Team" by using a single formula in cell A2. The reason for this is that in the end I want to use those values to filter the query result so that it doesn't show data for inactive people. (...WHERE Col1<>"No"...)
try removing that 1 in INDEX which will solve your ARRAY_ROW error:
=INDEX(Team!A2:A, MATCH('Quiz results'!F9:F, Team!G2:G, 0))
fyi, there is VLOOKUP:
=INDEX(IFNA(VLOOKUP('Quiz results'!F9:F, {Team!G2:G, Team!A2:A}, 2, 0)))
I'm attempting to use data on another page (scholar progress reports) to match columns in a current page (copy of results).
Using the formula below:
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A="&'Scholar Progress Reports'!A158&"")
Is producing the following error:
"Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: test"
where 'test' is the value of the cell I'm trying to match on the current page.
Assuming 'test' is in cell A158 of the same sheet, the query is used, try:
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A='"&A158&"'", 0)
Else, try
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A='"&'Scholar Progress Reports'!A158&"'", 0)
My immediate thought is exactly what the error says "NO_COLUMN: test". In your formula, are you trying to select a column, or something like that, called "test" instead of using the names "A", "B", etc.?
If that's not it, do you have a sample sheet?
THIS may also help.
I'm trying to combine the data in two sheets into another sheet by using the below code:
=UNIQUE(ArrayFormula(query({filter('Sheet1'!A2:B,NOT(ISBLANK('Sheet1'!A2:A)));filter('Sheet2'!A2:B,NOT(ISBLANK('Sheet2'!A2:A)))},"order by Col1")))
It works perfect if both sheets have at least 1 row filled but if either of the tabs are empty, then I receive #Value.
How can I fix this code so that it still works if either of the tabs are empty?
Filter throws an error instead of returning no values, a property that is very annoying in this case.
Since you're already using the query command why don't you try this, either one or both ranges can be completely empty.
=UNIQUE(ArrayFormula(query(
{Sheet1!A2:B; Sheet2!A2:B},
"WHERE Col1 is not null order by Col1")))
Alternatively if Col1 contains always strings a shorthand is Col1 <> ''
My goal is to fill down formula while data exist in an adjacent column.
Here is my original formula:
=index(lookups!$M$2:$M30,match($A3,lookups!$N$2:$N30,0))
This formula works in that results are returned as expected.
I then tried this in the hope of it copying down:
=index(lookups!$M$2:$M30,match($A3:A,lookups!$N$2:$N30,0))
This resulted in #N/A "Did not find value in match"
Then I read this post and looked at the second most voted answer and tried editing my formula to this:
=arrayFormula(index(lookups!$M$2:$M30,match($A3:A,lookups!$N$2:$N30,0)))
This time the formula copy down as I hoped, but with a #VALUE error "Function IF parameter 1 expects boolean values. But 'ADT- Alaska Travel Vendor Activities (Search)' is a text and cannot be coerced to a boolean."
How can I tell sheets to copy the index(Match()) all the way down while data exist in column A?
See if this formula delivers the desired output ?
=ARRAYFORMULA(iferror(vlookup(A3:A, {lookups!$B$2:$B, lookups!$A$2:$A}, 2, 0)))