Excel average not working when averaging from an IF Statement - excel

I have a column with =IF(E2="W ",H2,IF(I2<>"",I2,"")) in it.
It displays values but when I take an average of the column, it comes up with a divide by zero error.
Is there a special type of average function I need to use for this?

I assume that H2 and/or I2 are numbers? Perhaps those numbers are text formatted (in which case AVERAGE, not finding any true numbers will return #DIV/0! error). Try converting like this:
=IF(E2="W ",H2+0,IF(I2<>"",I2+0,""))
+0 will convert a text-formatted number to an actual number, then your AVERAGE function should work

Related

How do I get the count of values from a geometric sequence that fits in a number

I'm not even sure how to explain what I am looking for, but I will give it a try.
The image below shows a geometric sequence in column "LIST"
I'd like to get the count of values of numbers of column "LIST" from for the numbers in column "TEST" in column "NBR"
e.g. The value 116 is a combination of the numbers 64,32,16 and 4, hence the outcome should be 4 (because it takes 4 values to get to 116) in column "NBR"
Can this be done with a excel formula?
As per #HighPerformanceMark, you seem to want to convert a decimal to a binary number to count how many 1s are used. You can use the DEC2BIN() function for this which accepts positive decimals upto 511:
=LEN(SUBSTITUTE(DEC2BIN(B2),0,""))

Excel: Median of even number of values with a condition

When I calculate the median of even numbers for e.g 1,2,3,4,5,6,7,8.. i want the return value to be 5 i.e. the higher value of the two middle values and not the average of 4 & 5. Please help
I don't have Excel, so I can't try it, but I think you should be able to accomplish this with a combination of the LARGE function the COUNT function, and the TRUNC function. For example, if the numbers you are working with are in cells A1 through A8, you should be able to find the answer you want, though technically it's not the median, with the formula
=LARGE(A1:A8,TRUNC(COUNT(A1:A8)/2))
Edit
=LARGE(A1:A8,TRUNC((1+COUNT(A1:A8))/2))
If you know you will always be working with an even number of entries, the call to TRUNC could be omitted.
With data in column A:
=IF(ISODD(COUNT(A:A)),MEDIAN(A:A),ROUNDUP(MEDIAN(A:A),0))
EDIT#1:
Consider the array formula:
=IF(ISODD(COUNT(A:A)),MEDIAN(A:A),MIN(IF(A:A>MEDIAN(A:A),A:A)))
If the number of values is odd, return the median. If the number of value is even, return the smallest value greater than the median.
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
This approach does not require the data to be sorted.
EDIT#2:
This array formula appears to handle Ron's case:
=IF(ISODD(COUNT(A:A)),MEDIAN(A:A),MIN(IF(A:A>=MEDIAN(A:A),A:A)))
It returns the smallest value greater than or equal to the median (for the even case)
But I don't know if this is what the Poster wants.
=LARGE(A1:A9,INT((COUNT(A1:A9)/2)+0.5))
you can use Roundafter the Median
in your case you can type: =ROUND(MEDIAN(B4:I4),0)
lets say that the given range is from B4 to I4 from 1 to 8.

using array formula to average if

i have some cells d1:d10. Some have numbers, others contain "". The "" is the result of an =iferror(,"") function to leave a blank cell.
I am trying to average d1:d10 but only including the cells that are not "".
I have =AVERAGE(IF(D12:D51<>"",D12:D51)) followed by ctrl+shft+enter but it is still taking the average of all the cells (essentially taking the sum and dividing by 10, where I want it to take the sum and divide by less than 10 depending on the number of "" cells)
I couldn't reproduce your problem in Excel 2013.
Normally, Excel's average function ignores text, empty cells and logical values. So, the following formula should do what you are trying to do.
=AVERAGE(D1:D10)
The if clause in your function returns either some numbers or FALSE. Again, normally, Excel's average function ignores FALSE values so it shouldn't behave like you said. If it somehow is converting boolean values to numeric values based on Excel's version (FALSE to zero) you can just give a string instead of a boolean value so it has to ignore those values:
=AVERAGE(IF(D1:D10<>"", D1:D10, "s"))
Alternatively you can calculate the average without the average function:
=SUM(IF(D1:D10<>"", D1:D10))/COUNT(IF(D1:D10<>"", D1:D10))

Excel Formula to find max value in array

I'm using the below formula to find the Maximum income in a data set (entered as an array):
{=MAX((DATA!$B$2:$B$10000=1)*(DATA!$M$2:$M$10000=MAXINCOME!$D6)*(DATA!$A$2:$A$10000))}
Column B is the product, M is an agent and A is the range of values. However, any negative values return as 0. For some agents, all their values will be negative but I'm struggling to adapt this formula so if that scenario occurs the number closest to 0 is returned. Can anyone please help?
By multiplying the conditions with the values you get zeroes when the conditions don't apply for any row, so you always get a minimum of zero as MAX - try using nested IFs so that doesn't happen, i.e.
=MAX(IF(DATA!$B$2:$B$10000=1,IF(DATA!$M$2:$M$10000=MAXINCOME!$D6,DATA!$A$2:$A$10000)))
confirmed with CTRL+SHIFT+ENTER
That version can give you a negative result
....also MAX will return zero if there are no rows where the conditions are satisfied. That may be confusing if MAX values can include negative numbers (and possibly zero) so it might be better to use LARGE function here instead - that will give an error if there are no matching rows (but the same results otherwise), so you can then "error trap" the error and return an appropriate text value, e.g.
=IFERROR(LARGE(IF(DATA!$B$2:$B$10000=1,IF(DATA!$M$2:$M$10000=MAXINCOME!$D6,DATA!$A$2:$A$10000)),1),"No matches")

Excel - Return the first negative number of a column

I'm using Excel 2010 and I'm looking for a way to return the first negative number of a column. For instance, I have the following numbers distributed in a column:
1
4
6
-3
4
-1
-10
8
Which function could I use to return -3?
Thanks!
This could be interpreted two ways... If all the numbers are in a single cell (one column) as a string, the MID function can be used. If the numbers are in A1, a formula that could work is this:
=VALUE(MID(A1,SEARCH("-",A1),SEARCH(" ",A1,SEARCH("-",A1))-SEARCH("-",A1)))
If the numbers are each in their own columns (in my example, A3:H3), a different technique must be used:
{=INDEX(A3:H3,1,MATCH(TRUE,A3:H3<0,0))}
Don't type the { } - enter the equation using CTRL+SHIFT+ENTER.
In each case, the formula will return the number -3, which is the first negative number in the series.
Another possibility, avoiding the array formula (which are a big source of performance issues):
=LOOKUP(1;1/(M2:M15<0);M2:M15)
(I assume your numbers are in the M2:M15 range).
This will return the first number matching the "<0" condition. You may use any other condition, including text comparisons.
You may also extract the value of another array corresponding to the matching cell:
=LOOKUP(1;1/(M2:M15<>"OK");T2:T15)
In this example, the first cell containing another string than "OK" will be searched for in the m2:m15 array and the corresponding value in array t2:t15 will be returned.
Please note that the usage of the lookup function should be avoided whenever possible (but in this case, it's very handy !)
(I got the original inspiration for this answer from this post)

Resources