Nested if formula with % range - excel

90% + Ist Division
71% - 90 % IInd Division
40% - 70% IIIrd Division
< 40% Fail
Nested if excel formula for excel for above condition .
I applied below formula but seems to be not correct:
=IF(AND(i4>=40%,i4<=70%),"3rd",IF(AND(i4>=71%,i4<=90%),"2nd",IF(i4>90%,"ist"),IF(i4<40%,"fail")))

Start at the top:
=IF(I4>.9,"1st",IF(I4>=.71,"2nd",IF(I4>=.4,"3rd","FAIL")))
This way one only needs to step through the lowest threshold. Once one of the Ifs returns true it will not do the others.

Related

IF function in Excel - giving errors

I want to writte an If function with the following condition:
80% > value then 0 point
85% > value >= 80% then 1 point
90% > value >= 85% then 2 points
95% > value >= 90% then 3 points
97.5% > value >= 95% then 4 points
value >= 97.5% then 6 points
This is what I wrote, but I got an error for cases < 97.5%. I don't know where I did wrong. Please help
" =if(value >=97.5%,6,IF(AND(value >=95%,value <97.5%,4,IF(AND(value >=90%,value <95%),3, IF(AND(value >=85%,value <90%),2,IF(AND(value >=80%,value <85%),1,0)))))) "
By restructuring your IFs, you can do away with the need to check the upper bounds of each band, and therefore the ANDs which are less efficient.
Please see the formula below where your value is in cell A1:
=IF(A1 >= 97.5%, 6,
IF(A1 >= 95%, 4,
IF(A1 >= 90%, 3,
IF(A1 >= 85%, 2,
IF(A1 >= 80, 1, 0)
)
)
)
)
P.S. You can add new lines in the Excel formula bar by holding Alt and pressing the Enter key. This allows you to format your formulas to make them easier to read.
Easy Updates With Reference Table
The solution above is fine, if it is a one off formula that won't change often. However, if you have the formula repeated in numerous places and may need to change the cut offs or points associated with them often, it will quickly become labourious and error prone to find and update all the formulas.
The answer to this is to keep the cut offs and points in a separate reference table (which could be kept on a hidden sheet) and use a formula to look up the number of points that should be awarded. That way, you only have to update the table, and not each formula.
=INDEX($E$2:$E$7,MATCH($A$1,$D$2:$D$7,1))

Calculate the average % of a compounded increase with Excel formulas

I'm trying to calculate the average % of a compounded increase.
For example, if $100 increases by 5% over three years, the average % increase over the whole period is 10.34%.
100.00 + 5% = 105.00, 105.00 + 5% = 110.25, 110.25 + 5% = 115.76, AVERAGE(105,110.25,115.76) = 110.34, (110.34 - 100) / 100 = 10.34%
I'm currently calculating this with lots of IF statements because duration, percent, and starting values are variable…
=((100*1.05+IF(3>=2,100*(5/100+1)^2)+IF(3>=3,100*(5/100+1)^3))/3-100)/100
my actual formula contains many, many more lines to catch durations up to 25 years which is why I'm looking to scale it down with some intelligent calculations
The results will be shared with other teams who don't use VBA, so needs to utilize in-built formulas.
Thank you,
Your basic formula would be:
=(AVERAGE(FV(0.05,{1,2,3},0,-100))-100)/100
This is an array formula and must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Now if one wants the inputs to be dynamic(pointed at input cells) then we need to change the formula a little:
=(AVERAGE(FV(B2,ROW($ZZ$1:INDEX($ZZ:$ZZ,B1)),0,B3))+B3)/(-B3)
Still an array formula
NOTE: If one has the dynamic array formula SEQUENCE it can be done without the need of CSE with:
=(AVERAGE(FV(B2,SEQUENCE(B1),0,B3))+B3)/(-B3)
The math solution is
=((1+R)^N-1)*(1+R)/(R*N)-1
where R is the rate and N is the number of periods.

How to exclude zero entry from a dynamic formula (SUBTOTAL + SUMPRODUCT) in excel

I'm working on a formula to get the standard deviation. It has been working not until I encountered a zero value which makes the result into #DIV/0!.
This is the screenshot of the expected value.
However, when I used my formula, the Game Time SD returned 0.
How do I exclude it in the calculation if the value in F column is zero? I tried IF(F5:F9 <> 0) but it won't work.
This is the formula I used.
F3 = IFERROR(SUBTOTAL(1,F5:F9),0)
G3 = IFERROR(SUMPRODUCT(SUBTOTAL(2,OFFSET(F5:F9,ROW(F5:F9)-MIN(ROW(F5:F9)),,1))*(G5:G9*F5:F9))/SUBTOTAL(9,F5:F9),0)
H3 = IFERROR(((SUBTOTAL(9,F5:F9)*(SUMPRODUCT(SUBTOTAL(2,OFFSET(F5:F9,ROW(F5:F9)-MIN(ROW(F5:F9)),,1)) *
((H5:H9^2*F5:F9*(F5:F9-1)+(G5:G9*F5:F9)^2)/F5:F9)))-(SUMPRODUCT(SUBTOTAL(9,OFFSET(G5:G9,ROW(G5:G9)-MIN(ROW(G5:G9)),,1)),SUBTOTAL(9,OFFSET(F5:F9,ROW(F5:F9)-MIN(ROW(F5:F9)),,1))))^2)/(SUBTOTAL(9,F5:F9)*(SUBTOTAL(9,F5:F9)-1)))^(1/2),0)
I know the problem is somewhere in F5:F9, since the divisor used is zero
The part you suspected in the code involves dividing by a denominator that happens to be a factor in the numerator. You can avoid a division by zero by simplifying that fraction.
((H5:H9^2*F5:F9*(F5:F9-1)+(G5:G9*F5:F9)^2)/F5:F9)))
can be reduced to
(H5:H9^2*(F5:F9-1) + (G5:G9^2*F5:F9))
Resulting in the formula (3rd line modified)
=IFERROR(((SUBTOTAL(9,F5:F9)*
(SUMPRODUCT(SUBTOTAL(2,OFFSET(F5:F9,ROW(F5:F9)-MIN(ROW(F5:F9)),,1))*
(H5:H9^2*(F5:F9-1) + (G5:G9^2*F5:F9))))-
(SUMPRODUCT(SUBTOTAL(9,OFFSET(G5:G9,ROW(G5:G9)-
MIN(ROW(G5:G9)),,1)),SUBTOTAL(9,OFFSET(F5:F9,ROW(F5:F9)-
MIN(ROW(F5:F9)),,1))))^2)/(SUBTOTAL(9,F5:F9)*
(SUBTOTAL(9,F5:F9)-1)))^(1/2), 0)
In my tests without the enclosing IFERROR, I could set some rows to zero and get values. Only when the square rooted subtotal was negative (which logically should not happen) was the result #NUM.
Hope this helps.

How to exclude 0 from MIN formula Excel

i need to know how can i exclude 0 from rows and get the MIN Value.
But also i need to exlude the F1 Cell.
Ex:
A B C D E F
1 0 18 20 0 150 = 18
but if i do this In excel with =MIN(A1,B1,C1,D1,E1) return 0.
Any help is appreciated.
Try this formula
=SMALL((A1,C1,E1),INDEX(FREQUENCY((A1,C1,E1),0),1)+1)
Both SMALL and FREQUENCY functions accept "unions" as arguments, i.e. single cell references separated by commas and enclosed in brackets like (A1,C1,E1).
So the formula uses FREQUENCY and INDEX to find the number of zeroes in a range and if you add 1 to that you get the k value such that the kth smallest is always the minimum value excluding zero.
I'm assuming you don't have negative numbers.....
Enter the following into the result cell and then press Ctrl & Shift while pushing ENTER:
=MIN(If(A1:E1>0,A1:E1))
Not entirely sure what you want here, but if you want to discount blank cells in the range and pass over zeros then this would do it; if a little contrived:
=MIN(IF(A1:E1=0,MAX(A1:E1),A1:E1))
With Ctrl+Shift+Enter as an array.
What I'm doing here is replacing zeros with the maximum value in the list.
if all your value are positive, you can do -max(-n)
Solutions listed did not exactly work for me. The closest was Chief Wiggum - I wanted to add a comment on his answer but lack the reputation to do so. So I post as separate answer:
=MIN(IF(A1:E1>0;A1:E1))
Then instead of pressing ENTER, press CTRL+SHIFT+ENTER and watch Excel add { and } to respectively the beginning and the end of the formula (to activate the formula on array).
The comma "," and "If" statement as proposed by Chief Wiggum did not work on Excel Home and Student 2013. Need a semicolon ";" as well as full cap "IF" did the trick. Small syntax difference but took me 1.5 hour to figure out why I was getting an error and #VALUE.
Throwing my hat in the ring:
1) First we execute the NOT function on a set of integers,
evaluating non-zeros to 0 and zeros to 1
2) Then we search for the MAX in our original set of integers
3) Then we multiply each number in the set generated in step 1 by the MAX found in step 2, setting ones as 0 and zeros as MAX
4) Then we add the set generated in step 3 to our original set
5) Lastly we look for the MIN in the set generated in step 4
{=MIN((NOT(A1:A5000)* MAX(A1:A5000))+ A1:A5000)}
If you know the rough range of numbers, you can replace the MAX(RANGE) with a constant. This speeds things up slightly, still not enough to compete with the faster functions.
Also did a quick test run on data set of 5000 integers with formula being executed 5000 times.
{=SMALL(A1:A5000,COUNTIF(A1:A5000,0)+1)}
1.700859 Seconds Elapsed |
5,301,902 Ticks Elapsed
{=SMALL(A1:A5000,INDEX(FREQUENCY(A1:A5000,0),1)+1)}
1.935807 Seconds Elapsed |
6,034,279 Ticks Elapsed
{=MIN((NOT(A1:A5000)* MAX(A1:A5000))+ A1:A5000)}
3.127774 Seconds Elapsed |
9,749,865 Ticks Elapsed
{=MIN(If(A1:A5000>0,A1:A5000))}
3.287850 Seconds Elapsed |
10,248,852 Ticks Elapsed
{"=MIN(((A1:A5000=0)* MAX(A1:A5000))+ A1:A5000)"}
3.328824 Seconds Elapsed |
10,376,576 Ticks Elapsed
{=MIN(IF(A1:A5000=0,MAX(A1:A5000),A1:A5000))}
3.394730 Seconds Elapsed |
10,582,017 Ticks Elapsed
min() fuction exlude BOOLEAN and STRING values.
if you replace your zeroes with "" (empty string) - min() function will do its job as you like!
In Microsoft 365 you can use the new function MINIFS
=MINIFS(A1:E1;A1:E1;">0")
gives 1
=MINIFS(A1:E1;A1:E1;">1")
gives 18
*replace ; with , if using english version
All you have to do is to delete the "0" in the cells that contain just that and try again. That should work.

Binning in Excel

Which formulae in MS Excel can we use for -
equi-depth binning
equi-width binning
Here's what I used. The data I was binning was in A2:A2001.
Equi-width:
I calculated the width in a separate cell (U2), using this formula:
=(MAX($A$2:$A$2001) - MIN($A$2:$A$2001) + 0.00000001)/10
10 is the number of bins. The + 0.00000000001 is there because without it, values equal to the maximum were getting put into their own bin.
Then, for the actual binning, I used this:
=ROUNDDOWN(($A2-MIN($A$2:$A$2001))/$U$2, 0)
This function is finding how many bin-widths above the minimum your value is, by dividing (value - minimum) by the bin width. We only care about how many full bin-widths fit into the value, not fractional ones, so we use ROUNDDOWN to chop off all the fractional bin-widths (that is, show 0 decimal places).
Equi-depth
This one is simpler.
=ROUNDDOWN(PERCENTRANK($A$2:$A$2001, $A2)*10, 0)
First, get the percentile rank of the current cell ($A2) out of all the cells being binned ($A$2:$A$2001). This will be a value between 0 and 1, so to convert it into bins, just multiply by the total number of bins you want (I used 10). Then, chop off the decimals the same way as before.
For either of these, if you want your bins to start at 1 rather than 0, just add a +1 to the end of the formula.
Best approach is to use the built-in method:
http://support.microsoft.com/kb/214269
I think the VBA version of the addin (step 3 with most versions) will also give you the code.
Put this formula in B1:
=MAX( ROUNDUP( PERCENTRANK($A$1:$A$8, A1) *4, 0),1)
Fill down the formula all across B column and you are done. The formula divides the range into 4 equal buckets and it returns the bucket number which the cell A1 falls into. The first bucket contains the lowest 25% of values.
General pattern is:
=MAX( ROUNDUP ( PERCENTRANK ([Range], [TestCell]) * [NumberOfBuckets], 0), 1)
You may have to build the matrix to graph.
For the bin bracket you could use =PERCENTILE() for equi-depth and a proportion of the difference =Max(Data) - Min(Data) for equi-width.
You could obtain the frequency with =COUNTIF(). The bin's Mean could be obtained using =SUMPRODUCT((Data>LOWER_BRACKET)*(Data<UPPER_BRACKET)*Data)/frequency
More complex statistics could be reached hacking around with SUMPRODUCT and/or Array formulas (which I do not recommend since are very hard to comprehend for a non-programmer)

Resources