Google Sheets ARRAYFORMULA unexpected result - google-sheets

I have been attempting to create a Google Sheets formula:
=ARRAYFORMULA(IFERROR(INDEX(P2:T,SMALL(IF(T2:T = "Sent",ROW(P2:P)-1),1))))
to fulfill the following requirement:
Look up the first result of cells containing the word "Sent" in the T column, and display contents of the T column of the same row.
But instead it's not giving me any result, just blank.

Related

Array Formula with Filter for merging multiple sheets in Google Sheets - problem with empty sheet

I am using this formula to merge multiple sheets (about 100, but for simplicity just stick with 3 sheets: Sheet1, Sheet2 and Sheet3), in which I do not know how many non-empty rows I have (also, they increase dinamically).
={FILTER(Sheet1!A2:L;LEN(Sheet1!A2:A));FILTER(Sheet2!A2:L;LEN(Sheet2!A2:A));FILTER(Sheet3!A2:L;LEN(Sheet3!A2:A))}
The formula works well if all the sheets have at least one row filled with values. However, the problems is that if, for example, Sheet2 is empty, the formula gets me an error:
In ARRAY_LITERAL, an Array Literal was missing values for one or more rows
How can I fix this error?
The problem is:
When your sheet is empty, error message is returned. But this message is just one cell.
Your array to keep it's shape needs all rows to have 12 columns (A to L)
That's why you have "array literal..." message
You should set a condition for that creates an empty row of 12 cells in case of error with empty content.
Try:
Iferror(FILTER(Sheet1!A2:L;LEN(Sheet1!A2:A));{""\""\""\""\""\""\""\""\""\""\""\""})
for a sheet that you know as empty
\ separator works for some sheet locales but for USA, UK use comma (as I see you use semicolon between your values in formulas so \ should work).

Google Sheets VLOOKUP across Mismatched Ranges in Multiple Sheets

This formula should look up in the A column of multiple sheets and when the match is found (in this case there are not duplicates in any A column of the different sheets), it gives back the value found in the cell next on the right to the match.
=ArrayFormula(IF(LEN(B5),VLOOKUP(B5,{SHEET1!$A$3:$B,SHEET2!$A$15:$B},2,FALSE),""))
But it gives a mismatch error and even if I make the ranges the same length the value in B5 is searched only into the first sheet of the range, in this case SHEET1!$A$3:$B.
Is is possible to make the formula work with ranges of different length from multiple sheets?
always when you construct the virtual array with array brackets {} both sides needs to be of the same size.
={A1:A10, B1,B10}
or:
={A1:C10; D1:F10}
in your case, the array literal error comes from mismatched rows when you use "infinite" rows by not specifying the end row. eg your sheet1 has more or fewer rows then your sheet2
=INDEX(IF(LEN(B5), VLOOKUP(B5, {SHEET1!A3:B; SHEET2!A15:B}, 2, 0), ))

#REF! error in google sheets

I have a spread sheet which can be viewed at https://docs.google.com/spreadsheets/d/1bhIV1ULLXhjdSO_5Q5l5ZNe7Zaxrj15CYMW88FMFgRU/edit?usp=sharing
The way the spread sheet works is when a selection from the list is made the specific cells reference a data table and fills in the respective cells. This works perfectly in excel and I just use Iferror to hide the circular references. This is not the case in google sheets as the #REF! error still appears. How can I rectify so that they no longer appear? I have tried unique but it makes all the cells bank even when a different selection from the drop down box is made.
You can use the ISREF() function for this. Combine it with an IF() and you're good to go:
IF(ISREF('sheetname'!A4), 'sheetname'!A4, "")
The problem is that the formula itself is fine but (for column N) 'Attributes-InSeason-Trade_Mach'!$L121 and the following rows evaluate to "".
This means for INDEX in Google Spreadsheets that it will use all rows which in turn would overwrite the data in the next row because INDEX will be returning a range, not a single cell.
The Formula itself is evaluating fine, it does not cause an error which is why IFERROR does not trigger the alterantive "", the problem happens after the evaluation when it is trying to display the data.
You can just wrap the INDEX Call inside of an IF like this (This is an example for Column N)
=IFERROR(IF('Attributes-InSeason-Trade_Mach'!$L110 <> "",
INDEX('Attributes-InSeason-Trade_Mach'!$H$110:$I$214,
'Attributes-InSeason-Trade_Mach'!$L110,
COLUMNS(Trade_Machine!$P$4:P4)), ""), "")

Import selected rows with query on importrange

I'm trying to import select rows from a Google spreadsheet based on the value of a single cell in each row.
As such, I'm using the following:
=query(IMPORTRANGE("KEY","Form Responses 1!A:L"), "select * where J contains 'DENIED' ")
Wherein the KEY is an actual spreadsheet Key. I tested the importrange part, that is without the query, to confirm it works. It does. Furthermore, within the Google Spreadsheet itself I can query the sheet and get it to work.
The error I receive is:
#VALUE Error Unable to parse query string for query parameter 2: NO_COLUMN_J
(There is a column J.)
When you use an importrange as a dataset, you need to refer to the columns by number rather than letter. The formula also works without 'select *'. Try:
=query(IMPORTRANGE("KEY","Form Responses 1!A:L"),"where Col10 contains 'DENIED'")

How to use IFERROR inside an array formula?

If any of the queries in an array formula do not have actual data to query in the range they are hitting they return #VALUE! and mousing over the array formula reveals an error. If I take those queries and wrap them in an IFERROR I get the same results.
If I take what I wrapped in an IFERROR and split it out into its own cell to validate the query it results in displaying the error clause which in this case is a 0.
Here is a link to an example sheet.
Sheet1 has sample data.
Sheet2 is intentionally blank to simulate the issue described above.
Sheet3 has three queries on it in various states. The top two are the array formulas I am attempting to work with. The bottom Query is the IFERROR split out into its own cell to show that the query does in fact work when separated from the rest of the sort(arrayformula(etc)).
Try combining both ranges (from both sheets) inside 1 query instead of using 2 queries, and wrap an IFERROR() around that single query:
=ARRAYFORMULA(IFERROR(QUERY({Sheet1!A1:I500; sheet2!A1:I500}, "Select * where Col7='no'", 0), 0))
See if that works for you ?

Resources