Google Sheet Query to pull rows with errors - google-sheets

I'm trying to utilize Google Sheet to pull out rows which has errors.
Below is a screenshot on how the raw data looks like (Raw Data 1):
Column A is the key, which is used in Column F to do a VLOOKUP in another tab. If not found, replace with a "-" string value, as below:
=IFERROR(VLOOKUP(A2,'Raw Data 2'!$A:$E,5,FALSE), "-")
Column G checks whether Column E = Column F.
Column H is a formula which is (F-E)/E. In this case, a "#VALUE!" error pops out due to column F, which is okay for now.
Below is my processed tab with the formula:
=QUERY('Raw Data 1'!A:J, "SELECT A,B,C,D,E,F,G,H,J WHERE F='-'")
I have also tried:
=QUERY('Raw Data 1'!A:J, "SELECT A,B,C,D,E,F,G,H,J WHERE H='#VALUE!'")
Both give me empty results. Is there a way to make the query work such that it picks up rows where the VLOOKUP in Column F fails, or when Column H returns an error?
Edit 1: I am not able to use "Filter" as my Query needs to exclude Column I.
Thanks!
Edit 2: Created a sample sheet for reference thanks to the suggestion of #player0: https://docs.google.com/spreadsheets/d/1Htj6O5VbGyRCB_X7Q0epIg8OkhrHEFYnMAH1HJckVDo/edit#gid=1568356550

Try this:
=FILTER('Raw Data 1'!A:J, 'Raw Data 1'!F:F="-")
Or:
=FILTER('Raw Data 1'!A:J, ISERROR('Raw Data 1'!H:H))
update:
=ARRAYFORMULA(QUERY(TO_TEXT('Raw Data 1'!A:J), "WHERE Col6='-'", ))

Related

Finding the first value in a row and getting the address using ArrayFormula

in this example table, I want to get the first "failed" or "passed" from result 1, 2, and 3 column. I already made a formula to get the first mentioned value using:
=IF(C2=C2,CELL("address",INDEX(D2:F2,MATCH(C2,D2:F2,0))),)
which works fine (the column result is from that formula)
But when I'm trying to use ArrayFormula on the formula, it only shows the first row value only. my ArrayFormula is like this:
=ArrayFormula(IF(C2:C4=C2:C4,CELL("address",INDEX(D2:F2,MATCH(C2:C4,D2:F2,0))),))
i think its because the INDEX and MATCH doesn't update as it goes down, any idea how to fix this?
Sheets link: https://docs.google.com/spreadsheets/d/1oFTZHGd9PKpfZ9QXWvTshorEOGFxmD1cpeeQ9bIOYh8/edit?usp=sharing
You could use a query to get the minimum column matching the value in column C for each row in D to F:
=ArrayFormula(lambda(a,address(index(a,,1),index(a,,2)))
(query(split(flatten(if(C2:C="",,if(D2:F=C2:C,row(C2:C)&"|"&column(D2:F),))),"|"),"select Col1,min(Col2) where Col2 is not null group by Col1 label min(Col2) ''")))
Or alternatively you can use a formula similar to your original one with Byrow:
=ArrayFormula(if(C2:C="",,byrow(C2:F,lambda(r,CELL("address",INDEX(r,1+MATCH(index(r,,1),index(r,,2):index(r,,columns(r),0))))))))

Combining Query and If Statements in Google Sheets

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", )

How to get Date/ Time to work with Data Validation and INDEX(MATCH()) or VLOOKUP

I'm trying to set up a summary sheet that pulls relevant information based on input from three Data Validation drop-downs.
Link to the sheet: https://docs.google.com/spreadsheets/d/1LlOdONYI6hd2U5uVmD4C5i3WpuieOdohxIAnwfudUC8/edit?usp=sharing
I have a QUERY in 'Calculations'!E2, with Data Validation in 'Calculations'!F2 based on the results in 'Calculations'!E2, then two other QUERY in 'Calculations'!G2 and 'Calculations'!I2 with accompanying Data Validation in 'Calculations'!H2 and 'Calculations'!J2 respectively.
My first problem is when I get to the Data Validation in 'Calculations'!J2: Regardless of whether the selection looks identical to one of the times displayed in 'Calculations'!C:C, I always get an "Input must fall within the specified range" error.
My second problem: I can't get a formula to work that pulls the information I'm looking for from the "Form Responses" sheet. I've tried an INDEX(MATCH()) in 'Summary'!A8, and a VLOOKUP in 'Summary'!A10, but both say they can't find the date from 'Calculations'!J2.
I've tried adding/ removing significant digits with formatting and ROUND functions, but it won't match even though the data should be identical (the number in 'Calculations'!J2 is literally pulled directly from the dates in 'Form Responses'!A2:A, isn't it? Is that the problem?).
Thanks in advance for the help!
E2:
=UNIQUE(QUERY(A2:A, "where A is not null", 0))
G2:
=UNIQUE(QUERY(A2:C, "select B where A = '"&F2&"'", 0))
I2:
=ARRAYFORMULA(N(QUERY(A2:C, "select C where A = '"&F2&"' and B = '"&H2&"'", 0)))
K2:
=ARRAYFORMULA(IFNA(VLOOKUP(J2, {C2:C, A2:C}, {2, 3, 4}, 0)))

Google Sheets Arrayformula a Query

I originally have this formula:
=QUERY('Sheet1'!$C$6:$I, "Select F where D contains '"&$B86&"'")
This is applied to every cell from $B86 down to $B145. Users of the sheet accidentally deletes formula and adding protection isn't an option. So I'm thinking of adding the formula to the header only using arrayformula. However, arrayformula can't be used for query.
QUESTION 1:
Is there any other way around to get the same result when only the header has the formula?
={"Messages Sent";ARRAYFORMULA(QUERY('Sheet1'!$C$6:$I, "Select F where D contains '"&B86:B145&"'"))}
This is kinda what I want to achieve. However, this doesn't fill the data from B87 to B145. I only get the header and result for 1 row below the header.
Explanation
This shows the header ={"Messages Sent";
This is supposed to be the arrayformula ARRAYFORMULA(QUERY('Sheet1'!$C$6:$I, "Select F where D contains '"&B86:B145&"'"))}
This is the data from another sheet 'Sheet1'!$C$6:$I
This is the same data from the current sheet to find F in sheet 1 '"&B86:B145&"'
QUESTION 2: HOW CAN I GET THE ANSWER FROM THE QUERY AUTOMATICALLY SET INTO A NUMBER FORMAT SO I CAN DIRECTLY ADD THEM INSTEAD OF FORMATTING THEM MANUALLY AS NUMBER?
try maybe:
={"Messages Sent"; ARRAYFORMULA(IFNA(VLOOKUP(B86:B145,
{REGEXEXTRACT(""&Sheet1!D6:D, TEXTJOIN("|", 1, B86:B145)), Sheet1!F6:F*1}, 2, 0)))}

Google sheets wont filter a query

I am trying to filter a Google sheet with columns A to O using a query on a second sheet. I can put this formula in a new sheet and it pulls all the data just like its supposed to.
=query('Inventory'!$A$1:$O, "select * ", 1 )
What I am trying to do is filter the spreadsheet with a where clause that is to use a cell dropdown list (generated by unique values in the original sheet). I have used this formula:
=query('Inventory'!$A$1:$O, "select * where B = "&C1&"", 1 )
where C1 has the drop down box. This always gives me the error:
"Error
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: value" (the value depends on what is selected in the drop down).
It also doesn't work if I wrap the B = "&C1&" in parenthesis () which i have seen other posts use.
When I looked at Google's site for their example (https://support.google.com/docs/answer/3093343?hl=en), this should be a no-brainier unless something changed and their site isn't up to date.
I apologize for something this simple.
Try
=query('Inventory'!$A$1:$O, "select * where B = '"&C1&"'", 1 )

Resources