Excel Index of Bottom Element in Column but > 0 - excel

I have column A that is full of numbers ranging from 0 to 100. How can I get the index of the bottom element, but which is bigger than 0.
For example
6
7
9
1
0
8
0
In this example the number returned should be "6", as it's the index of the cell that contains "8".

You want to use the array form of MATCH():
=MATCH(1E+99,IF($A$1:$A$7<>0,$A$1:$A$7))
Being an array it needs to be confirmed with Ctrl-Shift-Enter when exiting edit mode instead of Enter. If done properly excel will put {} around the formula.
This will find the last number in the range that is not 0.
If your list is not static, the list changes length, then you can use this formula which will grow and shrink as the data in column A changes:
=MATCH(1E+99,IF($A$1:INDEX(A:A,MATCH(1E+99,A:A))<>0,$A$1:INDEX(A:A,MATCH(1E+99,A:A))))
It is still an array and being an array it needs to be confirmed with Ctrl-Shift-Enter when exiting edit mode instead of Enter. If done properly excel will put {} around the formula.
Array formula's calculations are exponential and therefore we want to limit the size of the dataset being tested to the extents. The two INDEX(A:A,MATCH(1E+99,A:A)) find the last cell in Column A with a number and sets that as the last cell in the range.

Related

how to use product function if some range cells are blanks

I want to multiple three cell values after subtract from 100%,I used product function and also tried aggregate function.i get error when if one of cell is blank.need subtract c cloumns value f colum n value and i column value from 100% then multiple.please note sometimes one of c ,f of i values can be blank.
As #BigBen stated, the only way you get this error is if there is a formula that returns a null string or space in the field.
To get around that we just need to use IFERROR to deal with the resulting error:
=PRODUCT(IFERROR(1-CHOOSE({1,2,3},C3,F3,I3),1))
Depending on ones version of Excel this may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Or since there is only three just use three IFERRORs and multiply the results:
=IFERROR(1-C3,1)*IFERROR(1-F3,1)*IFERROR(1-I3,1)
This is just a normal formula.
A third option is to return 0 instead of "" in your original formula:
=IFERROR(E3/D3,0)
Then format the cell %;%;; and it will hide the 0

Excel 2003: Averaging every Nth row

I am using Excel 2003 and am trying to average every two rows of data in one column,
starting from A1 and ending in A4, for example,
1
2
1
2
I try to do this average on the B1 column/row as follows (based on this info)
=AVERAGE(IF(MOD(ROW(A1:A4),2)=0,A1:A4))
However, when doing the above, B1 returns a 0, even though I intended to get a 1.
What would be the best way to make this kind of averaging work?
=AVERAGE(IF(MOD(ROW(A1:A4),2)=0,A1:A4))
The above formula is an array formula. To finalize it you need to press ctrl+shift+enter simultaneously; not just enter. This has also been abbreviated as CSE.
When you do this correctly, excel will wrap the formula in braces (e.g. { and }) like this:
{=AVERAGE(IF(MOD(ROW(A1:A4),2)=0,A1:A4))}
You do not type these braces in yourself; they are added automatically when a formula is entered as an array formula.
The solution to the question was as follows:
{=AVERAGE(IF(MOD(ROW(A1:A4)-1,2)=0,A1:A4))}
where the {} appears after pressing ctrl+shift+enter due to it being an array formula (cannot type that in manually).
The -1 is the offset based on where the data starts, and depending on the modulus operation, since MOD(ROW(A1),2) was 1,
i.e.: if my data instead started on A27, and I instead wanted to average values in every 4 rows, then MOD(ROW(A27),4) would return a 3 and the formula would correspondingly be offset by -3.
You could avoid array formulas using the below:
=IF((INT(ROW()/2)=ROW()/2)=TRUE,AVERAGE((A1,OFFSET(A1,-1,0))),"")
Image:

Array not outputting last cell

Following on from this question:
Array that outputs cells in a column AFTER a certain point
I have made a simplified example to test the formula
=IFERROR(INDEX($A$1:$A$11,SMALL(IF(ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))>MATCH("WORD",$A$1:$A$11,0),ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))),ROWS(A$1:A1))),"")
Here is my sample data In column A, and array formula in column B (Entered with ctrl + shift + enter)
:
The array is outputting the cells that are found after the WORD. However, you can see that 10 is not being displayed by the array.
I will display if I change all ranges in the formula to A1:A12, but this is not correct surely.
What is happening here?
You need to add 1 to the row output from the small, 11 - 1 = 10, So then you need to deal with the > Match by using >= MATCH:
=IFERROR(INDEX($A$1:$A$11,SMALL(IF(ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))>=MATCH("WORD",$A$1:$A$11,0),ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))+1),ROWS(A$1:A1))),"")
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

MAX + Left Function Excel

I am trying to get the max value of a column based on the Left function
What I am doing is the following :
These are the results I get when i write this into column C :
=MAX(LEFT(A:A, 2))
But what I truly want is to get in column C the max value of all column A not for each cell.
So the result should be in this case 90 for all rows.
What should be the formula here?
Just another option that gets entered normally:
=AGGREGATE(14,6,--LEFT($A$1:INDEX(A:A,MATCH("ZZZ",A:A)),2),1)
Array formulas will calculate the enitre referenced array. So care should be taken to limit the number of iterations to only the data set.
The $A$1:INDEX(A:A,MATCH("ZZZ",A:A)) part of the formula does that. It finds the last cell in column A with data in it and sets that as the upper bound. So in this instance the reference range is A1:A3. But, it will grow dynamically as data in Column A is added, so no need to change the formula each time data is added.
Update 2
Here is another solution which I think is better than my original (below)
=INT(SUMPRODUCT(MAX(SUBSTITUTE(A:A,"-",".")*1)))
it can be entered as normal (just Enter)
Orignal Answer
You need numbers and arrays
=MAX(IFERROR(LEFT(A:A,2)*1,0))
Let's break this down. Multiplying by turns your strings into numbers - since Left only returns a string
LEFT(A:A,2)*1
Unfortunately this method returns #Value if you multiply an empty string by 1. You will definitely have some empty strings in the range A:A so we wrap the whole thing with an IFERROR function.
IFERROR(LEFT(A:A,2)*1,0)
Now we still need excel to treat this as an array (i.e. a whole column of numbers, rather than just one number). So we put the MAX formula in and enter it with Ctrl+Shift+Enter rather than just Enter. The result is that the formula looks like this in the formula bar
{=MAX(IFERROR(LEFT(A:A,2)*1,0))}
which would return 90 in your example, as required
Update 1
If you are using Excel 2013 or later, you can also use the NUMBERVALUE function
=MAX(NUMBERVALUE(LEFT(A:A,2)))
again, enter it with Ctrl+Shift+Enter

How many different values appear in an Excel column?

I have a column of repeated texts (companies) mapped to a column on whether a condition was met.
How do I count how many companies met the condition? For example the picture below should yield 2 (counting 1 for "Google" + 1 for "Apple" and 0 for "Sun")
Use this array formula:
=SUM(IF($B$2:$B$11="Y",1/COUNTIFS($A$2:$A$11,$A$2:$A$11,$B$2:$B$11,"Y")))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Resources