I am trying to build a formula to calc the percentage of cells that are not "x" in a non-sequential range.
ie...
=COUNTIF(H10,N10,T10,Z10,AF10,AL10,B14,H14,N14,T14,Z14,AF14,AL14,B19,H19,N19,T19,Z19,AL19,B23,H23,N23,T23,Z23,AL23,"x")
I also tried using a named range
=(COUNTIF(my_rng,"x")
but neither are working
if there is a better way using countifs to do this as well that would help
essentially I want to find the percentage of a,b,c so if there is a way to countif header cell is "a" and cell directly under that is x?
output would be
A: 3
Assuming your sample is in Range A1:L11 and the strings a, b and c and in P2:P4, insert the following in Q2:
=COUNTIFS(A$2:L$10,P2,A$3:L$11,"x")
and populate down
edit: changed to Scott's more elegant solution
Related
Following this 2019 question and it's great answer I have learnt that to sum all cells that has formula, I should use:
=SUMPRODUCT((ISFORMULA(B5:M5)=TRUE)*B5:M5)
And to sum the cells that doesn't have formula, I should consider:
=SUMPRODUCT((ISFORMULA(B5:M5)=FALSE)*B5:M5)
But, can I use the above (or something else) in the way similar to using SUMIF with three arguments (summing values from other column than the one that is checked for conditions)?
Meaning that I need to solve following problem:
Sum all values in the range I2:I21, but only for those cells for which the corresponding cells in the range B2:B21 are not a formula / enumerable value.
I wonder if I'm not excepting too much and whether such a problem can be solved with just a formula, without using a macro.
The other answer posted under mentioned question has gave me an insight to solve this problem.
Using following formula:
=SUMPRODUCT((I2:I21)*(NOT(ISFORMULA(B2:B21))))
gives me exactly the values that I want. That is: sum of all values in I2:I21 range for which corresponding cell in B2:B21 range is a "hardcoded" value and not a result of an evaluable formula.
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.
Would like to use named range in order to find all relevant values in a range. However after several differrent approaches it seems that I cant't progress from here. Using *? in countif formula in order to get all text or values in the range, however it does not count the last cell with a text in the cell for some reason
=OFFSET(DATAMATCH!$I$7;0;0;COUNTIF(DATAMATCH!$I:$I;"*?");1)
An assumption:
Your range in column H are all these names
Column I range needs to have the same size as column H
The tricky part is that there are empty cells by formula in column H
So you could try the following (in my test a named range called TestRange2):
=DATAMATCH!$I$7:INDEX(DATAMATCH!$I:$I,MIN(IF(DATAMATCH!$H$7:$H$50="",ROW(DATAMATCH!$H$7:$H$50)))-1)
This way it's also non-volatile (or rather; semi-volatile), which using OFFSET wouldn't be.
Without the sheet's headings just guesswork, but worth trying changing that 7 to 8.
I wrote a formula which calculates the inputs in "Sheet2" which is below. So J4 is a cell of Sheet2:
=((COUNTIF((INDIRECT(ADDRESS(ROW(J4);COLUMN(J4))&":J"&
(MIN(IF(A4:A107="";ROW(A4:A107))))));"
<>"&""))-1)/((COUNTIF((INDIRECT(ADDRESS(ROW(J4);COLUMN(J4))&":J"&
(MIN(IF(A4:A107="";ROW(A4:A107))))));"<>0"))-1)
Now I want to write this formula to a cell in Sheet1.It means i should reference the Sheet2 for calculating the formula.
Can anyone help me with referencing?
EDIT: I still am without solution for this issue. Can anyone suggest me something new then in the comments?
Looking at your formula, it seems you want to evaluate ratio of:
Count non-blank cells in column J where column A is also non-blank.
Divide this count by count of non-zero cells in column J where column A is non-blank.
If yes then test following formula and see if it works per your needs:
=COUNTIFS(Sheet2!A4:A107,"<>",Sheet2!J4:J107,"<>")/COUNTIFS(Sheet2!A4:A107,"<>",Sheet2!J4:J107,"<>0")
Make sure you change argument separators.
Edit
In that case, you need to use following array formula (CTRL+SHIFT+ENTER) and change argument separators.
=COUNTIFS(Sheet2!A4:INDEX(Sheet2!A4:A107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>",Sheet2!J4:INDEX(Sheet2!J4:J107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>")/COUNTIFS(Sheet2!A4:INDEX(Sheet2!A4:A107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>",Sheet2!J4:INDEX(Sheet2!J4:J107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>0")
i have some data on excel and i have on column H a list of solutions and on column G a target box that moves from 0 to 100, and i already have a code to generate the solutions in column H , but i want a code to check the target value on column G and checks column H for the nearest solution number and then puts the answer on column I and highlights it.
thank you very much for your time and effort.
You could do without macro, using a service column, say J, and conditional formatting:
on column I place the formula =MAX(J$1:J$100)-J1 and copy/fill till row 100
similarly fill service column J with formula =ABS(G1-H1)
use conditional formatting in column I to highlight where value=0
You probably will need other function names, because spreadsheets use localized interfaces. For instance, for my test I used LibreOffice in Italian...
HTH
I am assuming that the 'solutions' are positive numbers. If these solutions are arranged in ascending order, then you can use the following formula. If not, one solution can be to use a helper column to sort the values in ascending order.
Let your list of solutions in column H be from H1:H100, and your target box is in cell G1.
Then you can copy the following formula to the cell you want.
=IF(MAX(H1:H100)<=G1,MAX(H1:H100),IF(INDEX(H1:H100,1+MATCH(G1,H1:H100))-G1>G1-INDEX(H1:H100,MATCH(G1,H1:H100)),INDEX(H1:H100,MATCH(G1,H1:H100)),INDEX(H1:H100,1+MATCH(G1,H1:H100))))
Replace H1:H100 everywhere in the above formula, with the range in which solutions are present in ascending order. Also, replace G1 everywhere with the address of the cell with the target value.
If solutions are not in an ascending order, then you can use a helper column. You use one extra column for sorting the solutions into an ascending order. If your solutions are present in H1:H10, then in cell I1, you can enter the following formula.
=IF(ISERROR(SMALL($H$1:$H$100,ROW()-ROW($I$1)+1)),"",SMALL($H$1:$H$100,ROW()-ROW($I$1)+1))
Replace $H$1:$H$100 in the formula with the range in which solutions are present. Also, replace $I$1 with the cell address of the same cell where you are copying this formula. Here, since I am copying this formula into I1, I have used $I$1.
Now copy this formula down till where you have the solutions, e.g. for this example, you will copy it down upto I100 since your solutions are from H1:H100.
Now in the previous formula, replace H1:H100 with I1:I100, as this new list is sorted in an ascending order.
If this is not what you are looking for, maybe you could give me some more details, as your question is not very clear. Hope this helps.
P.S. : You can add the highlighting later, if you get the value that you require.