Nested IF Statement (price bands) - excel

I am trying to create a formula using the following parameters:
=IF(E20<=500,E20*.90,IF(E20<=1000,E20*.80,IF(E20<5000,E20*.70,IF(E20<=10000,E20*.60,IF(E20<999999,E20*.50
I want the formula to calculate the price if the quantity falls within the range but am missing something with the formula above.
Could someone please point out the mistake and offer a suggestion or correction?

Since struggling with nested IFs (understandably!) you might be better off with a lookup table. Say name an array as below LT;
1 0.9
500 0.8
1000 0.7
5000 0.6
10000 0.5
and apply =VLOOKUP(E20,LT,2)*E20

With this, you check if cell A1 value falls between 100 and 200
=IF(A1 < 200; IF(A1 > 100; "ok"; "no"); "no")
Instead of "ok", you can insert your price calculation.
With this, you check if A1 < 100, if it is not then it checks if A1 < 200, and again if not it checks if A1 < 1000. If none of these conditions are true, it says "A1 > 1000"
=IF(A1 < 100; "A1<100"; IF(A1 < 200; "A1 < 200"; IF(A1 < 1000; "A1 < 1000"; "A1 > 1000")))
Again, instead of the optut string, you can insert your price calculation
Hope it helps, regards

Related

IF function for if x > y, but < yz multiple by b

So this is what I’m trying to do. If the percent of an output (let’s call it A1) is <75% multiply by 0. If it’s between 75-100% multiply by 1, if it’s between 100-150% multiply by 2, etc.
Scott Craner's MATCH answer is already good in the comments. But if you are looking for a plain IF function:
=IF(A1 < 0.75, 0,
IF(A1 < 1, B1,
IF(A1 < 1.5, B1 * 2)))
Although, I recommend using IFS for readability since we can opt not to include else values due to the non-conflicting conditions.
=IFS(
A1 < 0.75, 0,
A1 < 1, B1,
A1 < 1.5, B1 * 2
)
Sample Output:
Note:
Sheets read the formula left to right (top to bottom) so if it doesn't match the first condition, it will just proceed to the next one.
Feel free to adjust the ranges if it must be inclusive to the upper limit. (e.g < to <=)
Notice that 1st and 2nd values were not multiplied by 0 and 1, as we all know, the result would be 0 and the number itself respectively thus I opted from multiplying B1 to those numbers.
Sample outputs in the sheet shown are respective to their rows.
use:
=INDEX(IFNA(VLOOKUP(A1, {0.75, 0; 1, B1; 1.5, B1*2}, 2, 0)))

Excel: Rewriting Data into Buckets

I have the following values in an excel column:
11
84
167
241
520
I want to rewrite these column values as a group such that:
if cell value < 50 then A
if 50 < cell value < 100 then B
if 100 < cell value < 150 then C
if 150 < cell value < 250 then D
if cell value > 250 then E
I tried the following logic but it shows A for cell A1 and false for other values:
=IF(A1<50,"A",IF(50<A1<100,"B",IF(100<A1<150,"C",IF(150<A1<250,"D",IF(A1>250,"E")))))
We do not need to put the less than "< " expression because if it was less than "<" an earlier if then statement would have returned true. Note that a number such as 50, 100, 150 250 will return false as we are not using an inclusive less than expression. Less than or equals to <= may be what you need, but from your example I cant tell
=IF(A1<50,"A",IF(A1<100,"B",IF(A1<150,"C",IF(A1<250,"D",IF(A1>250,"E")))))
For future reference you have to break this up into separate statements
AND(50<A1,A1<100,"B")
vs
IF(50<A1<100,"B")

if statement in microsoft excel

this is my statement
=IF(G7 < 6, G7 * D22) + IF(5 < G7 < 11, G7 * D23) + IF(10 < G7, G7 * D24)
it works if G7 cell value is less then 6 or greater then 10, but if G7 value is from 6 to 10 the result is 0.
Cell D23 has value of 15.
What can be wrong?
Thank you
A wild guess, but you might want to edit the middle statement to this;
IF(AND( G7 < 5, G7 < 11), G7 * D23)
In the "Formulas" tab, "Formula Auditing" section you will find an "Evaluate Formula" button. This will show you the issue.
In the IF(5 < G7 < 11, G7 * D23) statement, when G7=6, the "5 < 6" portion evaluates to "TRUE". Next, this is evaluated as "TRUE < 11", which returns FALSE. This can be fixed by evaluating the comparisons to 5 and 11 separately.
IF(AND(5 < G12,G12 < 11), G12 * $D$23)
Personally, I would explicitly state the [value if false], but that's not strictly necessary.
=IF(G7 < 6, G7 * D22,0) + IF(AND(5 < G7,G7 < 11), G7 * D23,0) + IF(10 < G7, G7 * D24,0)
Try like this
=IF(G7<6,D22,IF(G7<11,D23,D24))*G7
You don't need an AND when you have nested IFs because the first IF has already dealt with <6 values so when the second IF is processed you only need the upper bound, similarly there is no 3rd IF because after the first two IFs all remaining values must fall in category 3
Mr. Pankaj Jaju gave correct answer.
=IF(G7 < 6, G7 * D22) + IF(AND( G7 >= 6, G7 < 11), G7 * D23) + IF(G7>=11, G7 * D24)
I tried it (actually I put AND(G7 > 5 instead of G7 >= 6), but it is the same) and it works.
Thank you

EXCEL How to write a step function

How do you return different values in a cell based on which range the value entered in another cell comes under? Specifically, I am trying to make a step function.
For example:
IF G2 is ABOVE "0" BUT BELOW "1" THEN display "0.1"
IF G2 is ABOVE "0.99" BUT BELOW "5" THEN display "0.15"
IF G2 is ABOVE "4.99" BUT BELOW "15" THEN display "0.2"
IF G2 is ABOVE "14.99" BUT BELOW "30" THEN display "0.5"
IF G2 is ABOVE "29.99" BUT BELOW "100" THEN display "1.0"
IF G2 is ABOVE "99.99" THEN display "1.30"
So IF G2 was "£18.75" then the cell that this formula is entered in would display "£0.50" based on the value's above.
(bear in mind that this is specific to my spreadsheet and was for calculating prices i.e. 0.99 = £0.99)
Following #oli_taz's suggestion, here is a slightly more robust solution that can deal with any input:
=IF(D4<F4, 0, VLOOKUP(D4,F4:G9,2))
with the range F4:G9:
0 0.1
1 0.15
5 0.2
15 0.5
30 1
100 1.3
and D4 being the value in question, e.g. 18.75 -> result: 0.5
Numbers smaller than 0 will return 0 and numbers larger than 100 will return 1.3.
Nested if's in Excel Are ugly:
=If(G2 < 1, .1, IF(G2 < 5,.15,if(G2 < 15,.2,if(G2 < 30,.5,if(G2 < 100,.1,1.3)))))
That should cover it.

How do I create a formula for "if x ≥ then multiply by y" and so on?

I've only used Excel for the basics.
I want to multiply the contents of the cell by a different number depending on the value in the cell. I have these ranges:
0 - 499, then multiply by 0
500 - 999, then multiply by 1
1000 - 1499, then multiply by 4
I was able to figure out the formula =IF(C21>=10000,C21*1) for if a value in cell C21 is greater than or equal to 10,000, but I don't see how to extend that to multiple ranges.
How can I write a formula to handle the multiple ranges I've listed above?
You can use another IF in the ELSE part of the expression, evaluation will stop as soon as a TRUE condition is met;
=A1 * IF(A1 < 500, 0, IF(A1 < 1000, 1, IF(A1 < 1500, 4, 0)))
(The last 0 is the case when the value is > 1499)
You can use nested IF statements for doing ranges:
=IF(C21>=500,IF(C21>=1000,IF(C21<1500,C21*4,'dontknowwhatyouwanthere'),C21*1),0)
How about nested Ifs?
=IF(A1<1000;IF(A1<500;+A1*0;+A1*1);+A1*4)
Then you've got:
If it's less than 1000 another if:
If it's less than 500 You do the " * 0 "
If it's not (you are at 500-999 range, from the first if) You do the " * 1 "
Else it's not less than 1000:
You have your " * 4 "
I used this formula and it worked:
=V4*IF(V4<600,0.2,IF(V4<800,0.22,IF(V4<1000,0.25,IF(V4<10000,0.27))))

Resources