I'm trying to make a COUNTIF that checks range E8:AI8 for the letter "D" and the range E7:AI7 for any of the following numbers 2;4;8;9;15;20;26;27;33;34;40;41
Also cells in range E5:AI5 to not equal any cell in C105:C118
E5:AI5 is dates in a calender.
C105:C118 is a list of dates for holidays.
My formular so far is looking like this:
Sumproduct(countifs($E$8:$AI$8;"*D*";$E$7:$AI$7;
{2;4;8;9;15;20;26;27;33;34;40;41};$E$5:$AI$5;"<>"&$C$105:$C$118))
However its not really turning out like i want it, the first two parts of the fomula are working as intended, but the last part comparing the row to the list of dates is not. Is it even possible to compare a row to a column? Or is there another way to do this?
That is not something you can do really inside a COUNTIFS() as described here. Consider to use SUMPRODUCT() with some MATCH() nested inside:
=SUMPRODUCT((E8:AI8="D")*(ISNUMBER(MATCH(E7:AI7,{2,4,8,9,15,20,26,27,33,34,40,41},0)))*(ISNA(MATCH(E5:AI5,C105:C118,0))))
Related
Im trying to count the duplicated values between the 2 row so im using the formula as you can see it in the image =SUM(COUNTIFS(E4:S4,{"1","2","3"}))
so I have to write the numbers so I dont want write the numbers I want select the cells instead, any formula would do that? I already searched and tried many things but nothing seem to work
Put those values in cells - and refer to those cells as condition.
Next level: insert those values in a table, that you eg. call FilterBy and the column values
Then you can us this formula:
=SUM(COUNTIFS(E4:S4,filterBy[Values]))
Hat I don't understand: why are you using SUM - like this, it doesn't make sense, as COUNTIFS returns one value.
If you want to some all filtered values then you need this formula:
=SUM(SUMIFS(E4:S4,E4:S4,filterBy[Values]))
Looking to try and find the following in Excel but am having issues getting this to work.
I have Dates in Column A which need to be checked against Dates in the Query Column to compare. I want to count all records where the comparison column is greater than the date in A5 or is an empty cell. There are other conditions that I will also want to check but cannot seem to get this to work.
=COUNTIFS(Query1[Purchased Date],OR(Query1[Purchased Date]="",Query1[Purchased Date]>A5))
use:
=SUMPRODUCT(--((Query1[Purchased Date]="")+(Query1[Purchased Date]>A5)>0))
You can use an array function instead of countif.
Suppose your dates are in the range A2:A25 and your reference date is in cell B2.
If you type in any other cell
=SUM((A2:A25>B2)+(A2:A25=""))
and hit Ctrl+Shift+Enter it will give you the count you want.
This happens because Excel will resolve the first inner parentheses (A2:A25>B2) as an array of TRUE/FALSE, and does the same to the second (A2:A25=""). Next it will sum them, which is equivalent to the OR operation, and yields as a result an array of zeros (FALSE) and ones (TRUE). It wraps up by summing this array (with the function sum), all in one cell.
Perhaps this is more of a comment than an answer, but in this particular case you can just add the two separate totals:
=COUNTIF(Query1[Purchased Date],"")+COUNTIF(Query1[Purchased Date],">"&A5)
because the conditions are mutually exclusive.
Whether this helps or not depends on what additional criteria you want to add.
BTW there are two issues with your original formula:
(1) If you are combining lists of values with OR logic, you have to use addition instead (as in the two answers which use Sum or Sumproduct).
(2) The syntax of a Countif or Countifs where the range has to be kept separate from the criteria won't let you do what you want to do, so this again leads you to Sum or Sumproduct.
Good day.
In it's basic form, I need to count how many cells are empty.
Using the following below, I can count how many cells are empty.
=COUNTIF(Sheet1!C:C,"<>")
However, if the cells in column C contain formulas, it won't work.
After some googling, I found out that using SUMPRODUCT will get what I need
=SUMPRODUCT(--(LEN(Sheet1!C:C)>0))
Now, here's my problem.
I need to use that as a criteria inside a COUNTIFS function, but I don't know how to do that because it's referencing some ranges.
So just to make it simple, using COUNTIF or COUNTIFS function specifically, how can I pass a criteria that checks if cell (with formula) is empty.
This formula returns 0 but most likely I'm just not passing it properly as a criteria.
=COUNTIF(Sheet1!C:C,SUMPRODUCT(--(LEN(Sheet1!C:C)>0)))
Happy for other ways to count cells (with formulas) which are empty, but I need to use it as a criteria for a COUNTIF/COUNTIFS function.
Thank you very much.
If I understand what you're looking for, you were pretty close already.
Following the formula's you already found you can use them like:
=COUNTIF(Sheet1!C:C,"<>")-SUMPRODUCT(--(LEN(Sheet1!C:C)>0))
It will result in the count of cells that have a value/formula minus the count of cells that show a value (blank formula result is excluded).
The result is the count of cells that contain a formula with blank result.
I'm trying to count the number of distinct text from a specific date in a data table.
Data Sample with expect result :
I was able to figure out how to count the distinct element from a range I specify, because I can determine the first and last row containing the date.
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
I have tried to modify my formula so that it determines the cell range by itself but without success.
I searched for an answer, using a combination of CELL and MAXIFS, example below, but Excel does not accept the formula.
=CELL("row",MAXIFS(A2:A15,A2:a15,D2))
I've looked at the INDEX formula, but I can't figure out how to do what I want to do. 😑
Any idea what I'm doing wrong, or what I should be doing instead?
Thanks, I appreciate it!
If you have Office 365 and the new Dynamic Arrays, this sort of formula has become ridiculously easy.
This formula in cell E3:
=COUNTA(UNIQUE(FILTER($B$2:$B$15,$A$2:$A$15=D3)))
Copy down.
You can also generate the unique list of dates with this formula in D3, which spills down automatically and does not need to be copied.
=UNIQUE(A2:A15)
It wasn't easy, but by separating each step of the problem, I was able to solve it.
Note that my solution only works because my dates are sorted.
Here's the final formula in the cell "One formula to rule them all":
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2))),INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)))))
Here are my explanations of my process:
Formula if I select the range :
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
Formula to get the first iteration
=ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2)
Formula to get the last iteration
{=ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)}
Create range from two addresses
=INDIRECT(CONCATENATE(F3,":",G3))
Formula giving me the expect result
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(F3,":",G3)),INDIRECT(CONCATENATE(F3,":",G3))))
I think that it's easier to explain my problem with an example:
Based on the spreadsheet above, the formula =DSUM(A4:D8,B4,A1:A2) works, returning 20.
Why =DSUM(A4:D8,B4,{"OrderID";">10567"}) does not work? (It returns #VALUE!)
Based on what's said about D-Functions on this page, I think you need to have the criteria in a separate cell.
EDIT: If the goal of including the criteria in the formula is to make it more readable, you could work with named ranges instead.
EDIT 2: In response to your comments.
It's not possible to do what you want (include the criteria in the formula) because of how the DSUM() function works. Take a look at the documentation for DSUM and compare it with VLOOKUP:
The syntax for the DSum function is:
DSum( range, field, criteria )
range is the range of cells that you want to apply the criteria against.
field is the column to sum the values. You can either specify the numerical position of the column in the list or the column label in double quotation marks.
criteria is the range of cells that contains your criteria.
Note the difference:
The syntax for the VLookup function is:
VLookup( value, table_array, index_number, not_exact_match )
value is the value to search for in the first column of the table_array.
table_array is two or more columns of data that is sorted in ascending order.
index_number is the column number in table_array from which the matching value must be returned. The first column is 1.
As DSUM is looking for a range of cells that contain the criteria, there's nothing you can do to avoid passing it just that - a range of cells.
I think the best you can do is define your different criteria as named ranges, which will make it a lot easier to reference the different ones depending on what you want to do in the formula. Unfortunately, if the regular SUM function is not fast enough for you, there's not much else you can do - you will have to specify criteria in cells to use DSUM.
You may use SUMIF(A5:A8;>10567;D5:D8). A very useful and underused function.
The 2nd parameter may be a REF to another cell with the condition.
From DSUM documentation
Criteria is the range of cells that
contains the conditions that you
specify. You can use any range for the
criteria argument, as long as it
includes at least one column label and
at least one cell below the column
label in which you specify a condition
for the column.
VLOOKUP uses an array of values.
table_array Required. The range of
cells that contains the data. You can
use a reference to a range (for
example, A2:D8), or a range name.
Dsum sucks, try this:
=SUMPRODUCT((A5:A8>10569)*(B5:B8))
Generally I would advise you not to hard code stuff like this, it's "bad practice", but as you like.