My understanding of the google sheets filter function is that it should limit the results to an array where the conditions are satisfied but I noticed this oddity:
Here is the sheet: https://docs.google.com/spreadsheets/d/1RL9cE6CYcpdNdkoKJvZc_KJ53d8QrNoMEQe-kH-4lo8/edit?usp=sharing
formula for result 1:
=filter(A2:A,A2:A<=105)
formula for result 2
=filter("x"&A2:A,A2:A<=105)
Question: Why does the 'x' continue down in rows where the condition is not satisfied?
Because empty cells treated as zero 0. You can add an addition condition to FILTER() function to filter values greater than zero 0.
=FILTER("x"&A2:A,A2:A<=105,A2:A>0)
Related
I am trying to type a logical formula like that :
=AND(OR(A1=0;B1);OR(A2=0;B2);OR(A3=0;B3);...;OR(An=0;Bn))
But I own multiples rows and I am searching for a faster way to achieve this operation.
Any idea ?
You can use ARRAYFORMULA()
ARRAYFORMULA
Enables the display of values returned from an array formula into multiple rows and/or columns and the use of non-array functions with arrays.
Sample Formula:
=AND(ARRAYFORMULA(IF(A2:A8=0,1,0)+(B2:B8)))
what this formula does is performing OR operation using "+" for Column A and Column B. Once the OR operation was performed, ARRAYFORMULA will return an array of results which you can use in your AND operation.
Example:
In the first scenario, when you performed an OR operation within the ARRAYFORMULA (See Cell C2, formula was shown in Cell C1) It will return an array of OR operation results per row. Then if you check the formula used in Cell D2, we just get the AND operation of the array results from ARRAYFORMULA
NOTE:
You cannot use AND() or OR() functions inside the ARRAYFORMULA(), instead we use '*' for AND() and '+' for OR().
Reference: ArrayFormula and "AND" Formula in Google Sheets
I am trying to use index to return values from a list created by an array formula. The array formula is:
aRRAYFORMULA(match(filter(full_list,startDate=N4,locationID=L4,service=M4),ID_list,0))
This array formula is essentially cross-referencing the filtered full_list with the ID_list to return positions of the ID's that are both in the full_list and ID_list. I'm now trying to turn the positions from the code above into the ID's found in the ID_list.
I've tried:
aRRAYFORMULA(index(ID_list,ifna(match(filter(full_list,startDate=N3,locationID=L3,service=M3),ID_list,0),""),1))
and
arrayformula(index(ID_list,aRRAYFORMULA(match(filter(full_list,startDate=N4,locationID=L4,service=M4),ID_list,0))))
but they only return the ID_list value for the first entry in the list. So say that the first formula returns 2 row positions, 4 and 20; the result of the formulas I've tried results is a single cell with the value for row position 4. The row position 20 is ignored.
Is there anything that I am doing incorrectly here and how do I fix this? Or, is there an easier way to achieve what I want, such as without an array formula?
I would forget about using INDEX altogether and just focus on an ARRAYFORMULA + FILTER + MATCH strategy:
=FILTER(ID_list,ARRAYFORMULA(ISNUMBER(MATCH(ID_list,full_list,0)))=TRUE)
If none of your ID_list values exist in full_list the formula will throw an error. If you want it to just report a blank, then add an IFERROR to your formula:
=IFERROR(FILTER(ID_list,ARRAYFORMULA(ISNUMBER(MATCH(ID_list,full_list,0)))=TRUE),"")
Hope it works for you!
I have a bunch of columns that holds scores like 3-1 1-4 1-0 2-2.
I would like to count all columns that are winning, ie. left number is higher than right one.
I have this formula to know if a column is winning : =LEFT(H2; FIND("-"; H2)-1)-RIGHT(H2; FIND("-"; H2)-1)
What I want to do now is to use this formula within COUNTIF, something along the line :
=COUNTIF(A1:A10; "LEFT(CURRENT_COLUMN; FIND("-"; CURRENT_COLUMN)-1)-RIGHT(CURRENT_COLUMN; FIND("-"; CURRENT_COLUMN)-1)")
Is there any way I can do it with a single formula ?
Complex filtering like this can be done with filter, and then the results can be counted with counta. Example:
=counta(filter(A:A, LEFT(A:A, FIND("-", A:A)-1) > RIGHT(A:A, FIND("-", A:A)-1)))
The first argument of filter is the range to be filtered; the second is a formula based on that range (or another range with the same row count) which returns True or False. The rows where the formula evaluates to True are returned.
The VLOOKUP formulas which works individually are
=if(VLOOKUP(E2,DB!$C:$E,1,0)>0,"COMPLETED",)
=if(VLOOKUP(E2,DB!$F:$H,1,0)>0,"IN PROGRESS",)
The issue is while displaying both results in a single cell, the formula which I came up for this was
C2=if(AND(VLOOKUP(E4,DB!$C:$E,1,0)>0),"COMPLETED",if(VLOOKUP(E4,DB!$F:$H,1,0)>0,"IN PROGRESS","UNDEFINED"))
I have tested the formula with normal conditions other than VLOOKUP and it works without any issues, not sure what's wrong with it.
Example : C10=if(AND(E10=1),"ONE",if(E10=2,"TWO","NO DATA"))
Any help appreciated.
May be its something simple but I am pulling my hair out for the last 3 hours.
Thanks :)
/-----------------------/
Updated 03.05.2016
Sorry for the comments that I have posted as I am new at using Stack overflow.
I have tried with only IF statements without any AND conditions, but the result is still same. The VLOOKUP is not returning the second value.
C15=IF(VLOOKUP(E15,DB!$F:$H,1,0)>0,"COMPLETED",if(VLOOKUP(E15,DB!$F:$H,1,0)>0,"IN PROGRESS","UNDEFINED"))
What I am expecting in cell C2 (sheet1) is check the values in cell
E2 against the columns C:H ( Sheet 2/ DB). If it belongs to
Column C:C in (sheet2/DB) then the value in C2 (sheet1) should display
as "Completed" else if the value is in column F:F ( sheet2/DB) then in C2
(sheet1) should display "In Progress".
Link to my spreadsheet link
There are a few problems with your formula.
VLOOKUP and similar functions search within a single row or column, and it seems like you're looking for your value in multiple rows and columns.
As #Meta mentioned, VLOOKUP returns N/A when the value is not found in the range, and you are expecting a zero or less value to be returned (when you check for >0 in the IF statement). Note that VLOOKUP returns the cell value itself and not an index of a match (like the MATCH function).
My suggestion is to replace your VLOOKUPs with COUNTIF.
=IF(COUNTIF(DB!$F:$H,E2)>0,"COMPLETED",IF(COUNTIF(DB!$C:$D,E2)>0,"IN PROGRESS","UNDEFINED"))
COUNTIF counts in multiple rows and columns, and will return a zero if no matches are found.
In a google spreadsheet I have the columns A and B populated with some data, then I have this formula to count the values in A if B=1:
=COUNTA(FILTER(A:A;B:B=1))
Problem is that the formula is counting 1 match even if there is no value matching the criteria.
This is the spreadsheet: https://docs.google.com/spreadsheet/ccc?key=0Ak9RViY8FJE5dF9PN3F2ZVFsenk3TG1LZkZjS0d4MHc#gid=0
Thats because the filter results in Error - showing the count 1 which is error...please try
=COUNTA(IFERROR(FILTER(A1:A3,B1:B3=1),""))
The error is being counted and the other result replaces the error with "" which would also return 1. If you want an empty filter result to return zero simply omit the second argument...
=COUNTA(IFERROR(FILTER(A1:A3,B1:B3=1)))