I'm having trouble with a countif that I am using to count the number of entries in a range. The problem is that the range is populated with an array formula, and when the data changes the cells the array formula added a =CONTINUE(...) to now display -- (minus minus)
=COUNTIF(C6:C, "<>")
Is there a way that the countif could be written to ignore cells with --?
The -- is a way that Google Sheets displays the #VALUE! error. So you can use the IFERROR function to "mask" any of these errors:
=ArrayFormula(COUNTIF(IFERROR(C6:C);"<>"))
or more simply:
=ArrayFormula(COUNTA(IFERROR(C6:C)))
Updated:
Why don't you filter out all cells that are not text or similar to --?
Then use filtered range for countif.
=COUNTIF((ROWS(C6:C)-COUNTIF(C6:C"<>*")) , "ur criteria")
Is there a way your formula array could cast a string other than --?
Check this article
The search you are doing has regular expression.
Writing this on mobile. So please try out and pardon for weird formatting.
Related
I am trying to get a VLOOKUP to work on an entire column (minus the header), but I want blank entries if the column I am searching for is empty. I tried both these formulas, but to no avail (I still get the N/A in empty cells):
=ARRAYFORMULA(IF(ISBLANK(VLOOKUP(O2:O,Sheet1!B:C,2,FALSE)),"",VLOOKUP(O2:O,Sheet1!B:C,2,FALSE)))
=ARRAYFORMULA(IF(O2:O<>"",VLOOKUP(O2:O,Sheet1!B:C,2,FALSE)),"")
This is a slightly more complicated way than what I got working in another part of my sheet, which is the same without the VLOOKUP:
=ARRAYFORMULA(IF(ISBLANK(J2:J),"",J2:J))
Any ideas what am I doing wrong?
If you want to leave a blank instead of #N/A in a cell, you can use =IFERROR.
Like this:
=IFERROR(Your_formula, "value if the formula returns an error")
Since you are using ARRAYFORMULA, the iferror must be inside it
=ARRAYFORMULA(IFERROR(VLOOKUP(O2:O,Sheet1!B:C,2,FALSE),""))
I have a range of cells in one column, some contain text and some are blank cells. I want to search the range for the first occurrence of a word. I know that it's possible to combine Index and Match functions to find exact text within a range of cells. But I need to search for partial matches. I've tried mixing using the Search function, but it doesn't seem to accept a range. How can I search a range for the first partial text match? I only want to use formulas, not script.
The search function can be applied to a range using arrayformula wrapper:
=arrayformula(search("str", C2:F9))
This returns a bunch of #value! errors where no match is found, or the position of substring when it's found. A more readable output is produced with
=arrayformula(if(iserror(search("str", C2:F9)), , C2:F9))
This leaves non-matches blank, and returns the actual cell content where there is a match. Or you could put row(C2:F9) at the end to get the row numbers, etc.
We can simply use vlookup or match formula to find a string from a specific range
Vlookup example:
=VLOOKUP(B2, $B$2:$B, 1, FALSE)
Match example:
=MATCH("Sunday",A2:A9,0)
=MATCH(DATE(2012,1,1),A2:F2)
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.
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 ?
I have several columns in Google Spreadsheet.
I would like to count how many cells have a value (number or string) and display that number at the top of the column.
For example:
Hello
World
123
Some string
The above column would give me the answer of "4"
I have not managed to find a formula that does this.
In the cell you want your result to appear, use the following formula:
=COUNTIF(A1:A200,"<>")
That will count all cells which have a value and ignore all empty cells in the range of A1 to A200.
You could also use =COUNTA(A1:A200) which requires no conditions.
From Google Support:
COUNTA counts all values in a dataset, including those which appear
more than once and text values (including zero-length strings and
whitespace). To count unique values, use COUNTUNIQUE.
An additional trick beside using =COUNTIF(...) and =COUNTA(...) is:
=COUNTBLANK(A2:C100)
That will count all the empty cells.
This is useful for:
empty cells that doesn't contain data
formula that return blank or null
survey with missing answer fields which can be used for diff criterias
Shorter and dealing with a column (entire, not just a section of a column):
=COUNTA(A:A)
COUNTA
Beware, a cell containing just a space would be included in the count.
The SUBTOTAL function can be used if you want to get the count respecting any filters you use on the page.
=SUBTOTAL(103, A1:A200)
will help you get count of non-empty rows, respecting filters.
103 - is similar to COUNTA, but ignores empty rows and also respects filters.
Reference : SUBTOTAL function