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]))
Related
I am trying to use an on sheet formula that will provide me with all the column numbers in which a value exists. For the sake of example: I want to find all the columns on Sheet1 that have a value of ThisHeader in Row1.
I have been able to use the below formula to retrieve the result I want if the value I'm searching for only appears one time:
=MATCH("ThisHeader",1:1,0)
I'm unsure how to implement this same logic, but give me multiple column numbers if ThisHeader exists in multiple columns.
I'm not particular about how the result is displayed, although ideally I'd use something like: =SUBSTITUTE(ADDRESS(1,col_number,4),"1","") after the column numbers are retrieved in order to translate to a letter format. perhaps with a comma or dash separating each number/column letter. I could add or use multiple formulas and columns rather than a nested formula as well if that is the best or only route.
Thanks in advance!
If you have O365, you can use:
=AGGREGATE(15,6,1/($1:$1="ThisHeader")*COLUMN($1:$1),SEQUENCE(COUNTIF($1:$1,"ThisHeader")))
If you do not have the SEQUENCE function, you can replace it and use:
=AGGREGATE(15,6,1/($1:$1="ThisHeader")*COLUMN($1:$1),ROW(INDEX($A:$A,1):INDEX($A:$A,COUNTIF($1:$1,"ThisHeader"))))
Results
The formula returns an array of the column numbers. So, to visualize them if you don't have the dynamic array feature of recent Excel versions, you may have to enter this as an array formula (with ctrl+shift+enter over multiple cells. Or by using an INDEX function to return each element.
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 conditionally format a column of cells based on whether the combination of two other columns appear in a Table.
Here is a link to the test workbook I am playing with and screenshots below for those that don't like clicking strangers links!
https://1drv.ms/x/s!Al1Kq21dFT1ij4ktFd0mzBniNX00tQ?e=L6aQm4
On the far left is an Excel table ([Table1]) that contains a list of valid combinations of [Category] and [Item]
Columns E&F contain some sample data to test against
Column G is the number of matching combinations I expect to return from a COUNTIFS() function
Column H is simply the same formula compared to 0 so I get a boolean result.
The actual formula to get the result shown in Column H is
=COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0
All the above works as expected.
In Column J is just some literal text with conditional formatting. The condition is simply =H4, again this works as expected.
Now to the problem...
I want to avoid having the helper column (H) so I thought I could just use the same formula that I used in column H, as my condition formula.
So, I tried to use this in the conditional formatting formula dialog.
=COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0
and with parantheses
=(COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0)
Unfortunately, this results in the generic "There's a problem with this formula" error message.
If might be that there are some limitations with conditional formatting formulae that I'm not aware of (I'm no Excel guru, I'm a SQL developer really).
BTW: I need to stick with using a table as my real-world scenario is that there will be several tables, all populated from a database via a separate process with lengths varying from 2 or 3 entries to potentially thousands.
I would appreciate any help, even if it's just to say "You can't do this, you'll need to use your helper column..."
Thanks for looking...
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))))
Hi I have a row of calculated values that I need to count based on a condition.
I have the conditions working in conditional formatting so that is the condition is met the cell changes color, however I need to find the totals of each color.
=AND($V1/$Z1>0.5, $V1/$Z1<=0.79)
so for this I want to only count values if this statement is true
=COUNTIF(Z:Z, (AND($V1/$Z1>0.5, $V1/$Z1<=0.79)))
currently this returns 0 when there is 10 values that meet this criteria
does anyone know if countif can be used like this?
I can see your issue, I've had a play around and am unable to crack it, if you wish to keep it in a singular cell you'll probably need to go down the route of an array formula. Its probably complicating it too much and you should look to have a helper column,
in Column AA, have the formula =$v1/$z1, then for your count write:
=countifs(AA:AA,">0.5",AA:AA,"<=0.79")
This can be done without a helper column using the Sumproduct() function.
=SUMPRODUCT(--($V$1:$V$100/$Z$1:$Z$100>0.5),--($V$1:$V$100/$Z$1:$Z$100<=0.79))
or
=SUMPRODUCT(($V$1:$V$100/$Z$1:$Z$100>0.5)*($V$1:$V$100/$Z$1:$Z$100<=0.79))
This will count all instances where the values in V1 to V100 divided by the values in Z1 to Z100 are between 0.5 and 0.79
Note that SumProduct is essentially an array formula (even though it does not require confirmation with Ctrl-Shift-Enter, but it evaluates each range as an array), so you don't want to use it with whole column references. If you want to retain calculation speed, make sure to refer to used rows only, not gazillions of empty cells.