I have a price list in which customers will be charged different amounts according to how many products they order and if they are an existing customer.
I am trying to write a nested IF with AND statement with the following conditions:
Order 1-10 and TRUE = 3*1.2
Order 1-10 and FALSE = 3
Order 11-20 and TRUE = 2*1.2
Order 11-20 and FALSE = 2
Order 21 or more and TRUE = 1*1.2
Order 21 or more and FALSE = 1
So far I have a formula which works but is less than elegant where B1 is the order volume, B2 is existing customer and E1/F2/F3 are the prices.
=IF(AND(B1<11,B2=TRUE),E1*1.2,IF(AND(B1<11,B2=FALSE),E1,IF(AND(B1<21,B2=TRUE),F1*1.2,IF(AND(B1<21,B2=FALSE),F1,IF(AND(B1>=21,B2=TRUE),G1*1.2,G1)))))
Is there a way to make this formula more short/efficient?
You could separate it out a bit like:
=If(B2, 1.2, 1)*If(AND(B1>=1, B1<=10), 3, If(And(B1>=11,B1<=20), 2, 1))
If you convert this over to math you could just do:
=If(B2, 1.2, 1)*ROUND(30/CEILING(B1, 10), 0)
Or:
=(1+B2*0.2)*ROUND(30/CEILING(B1, 10), 0)
That's getting a little silly though.
Updated for the E1/F2/F3 difference. I didn't catch that the first time around. I think the following would be the way to go (kind of a mix of option 1 and option 3 above).
=(1+B2*0.2)*If(B1<=10),E1,If(B1<=20), F2, F3))
I think the biggest gain is seperating out the logic to determine your multiplier (1.2 vs 1 depending on B1) and the logic for determining the price (your If statement and E1/F2/F3)
Related
After a bit of advice on doing a calculator with a sliding scale.
I am building a matrix where we have set price points at intervals based on qty of items. The code I use works fine apart from the first 2 ranges.
Because for 1 qty the unit cost is so high my maths won't work.
Example
Qty 1 = £23.25 (Price per unit is then £23.25)
Qty 10 = £51.59 (Price per unit is then £5.159)
I then have further quantity's that work out correctly.
What I need to be able to do is some sort of weighted value, for 2 off the unit price needs to be near the £20 a unit mark, then 3 off less etc until I get to 10 off # £5.159 a unit.
(It costs more for lesser quantity's, we want to encourage more qty)
Has anyone implemented something like this? From 10 qty onwards the calculation is fine as the unit cost changes are not much at all.
Thanks
Assuming you have quantities form 1 to 10, in column A, put 23.25 in B1 and 51.59 in B10, then the following formula in B2:
=B1+(B$10-B$1)/9
And populate down to B9
in C1 use the following formula:
=B1/A1
and populate down. Final result should look like this:
You could use vlookup with a table as so:
I have a formula that currently works pretty well for the most part. It originally was a scoring factor of 90%-100= 5, and 85% to 89.99% = 4 and 80% to 84.99% = 3 and so on. This is represented using the formula below:
=IF($B10>=90%,5,IF($B10>=85%,4,IF($B10>=80%,3,IF($B10>=75%,2,IF($B10<=74.99%,1)))))
So the new requirement came down as follows:
Range value picture
95 to 100% = 5
85 to 89.99% or 101.1 to 105% = 4
80 to 89.99% or 105.1 to 110% = 3
75 to 79.99% or 110.1 to 115% = 2
Less than 74.9 = 1
So the dilemma I'm in is I have not been able to figure out how to create a range for values 2, 3 and 4 to be either or side for the scoring value to become true. So score value 4 should be the ranges of 85% through 89.99% OR 101.1% through 105% to be true.
Does anyone have any ideas on how to restructure this to include the ranges so that if either range is true it would show the correct scoring values? Thanks in advance for your help.
Instead of nested ifs consider using a table then use a VLOOKUP to find the correct value:
I created this table:
Then I can use this formula to get the proper score:
=VLOOKUP(B10,E:F,2,TRUE)
This method has the advantage of being able to easily expand to accomadate new rules. The only caveat is that your table must be sorted on the first column to get the proper return.
I have this table in Excel:
I am trying to get weighted sum depending on two conditions:
Whether it is Company 1 or Company 2 (shares quantity differ)
Whether column A (Company 1) and column B (Company 2) has 0 or 1 (multipliers differ)
Example:
Lets calculate weighted sum for row 2:
Sum = 2 (multiplier 1) * 50 (1 share price) * 3 (shares quantity for Company 1) +
+0.5 (multiplier 0) * 50 (1 share price) * 6 (shares quantity for Company 2) = 450
So, Sum for Row 2 = 450.
For now I am checking only for multipliers (1 or 0) using this code:
=COUNTIF(A2:B2,0)*$B$9*$B$8 + COUNTIF(A2:B2,1)*$B$9*$B$7
But it does not take into account the shares quantities for Company 1 or Company 2. I only multiply 1 share price with multipliers, but not with shares quantity).
How can I also check whether it is Company 1 or Company 2 in order to multiply by corresponding Shares quantity?
Upd:
Rasmus0607 gave a solution when there are only two companies:
=$B$9*$E$8*IF(A2=1;$B$7;$B$8)+$B$9*$E$9*IF(B2=1;$B$7;$B$8)
Tom Sharpe gave a more general solution (number of companies can be greater than 2)
I uploaded my Excel file to DropBox:
Excel file
I can offer a more general way of doing it with the benefit of hindsight that you can apply to more than two columns by altering the second CHOOSE statement:-
=SUM(CHOOSE(2-A2:B2,$B$7,$B$8)*CHOOSE(COLUMN(A:B),$E$8,$E$9))*$B$9
Unfortunately it's an array formula that you have to enter with CtrlShiftEnter. But it's a moot point whether or not it would be better just to use one of the other answers with some repetition and keep it simple.
You could also try this:-
=SUMPRODUCT(N(OFFSET($B$6,2-A2:B2,0)),N(OFFSET($E$7,COLUMN(A:B),0)))*$B$9
Here's how it would be for three companies
=SUM(CHOOSE(2-A2:C2,$B$7,$B$8)*CHOOSE(COLUMN(A:C),$F$8,$F$9,$F$10))*$B$9
(array formula) or
=SUMPRODUCT(N(OFFSET($B$6,2-A2:C2,0)),N(OFFSET($F$7,COLUMN(A:C),0)))*$B$9
=$B$9*$E$8*IF(A2=1;$B$7;$B$8)+$B$9*$E$9*IF(B2=1;$B$7;$B$8)
Since in the COUNTIF function, you don't know beforehand, which company column contains a 0, or a 1, I would suggest a longer, but more systematic solution using IF:
=$B$9*$E$8*IF(A2=1;2;0,5)+$B$9*$E$9*IF(B2=1;2;0,5)
This is a bit less general, but should produce the result you expect in this case.
I am having trouble determining the correct way to calculate a final rank order for four categories. Each of the four metrics make up a higher group. A Top 10 of each category is applied to the respective product to risk analysis.
CURRENT LOGIC - Assignment of 25% max per category.
Columns - Y4
Parts
0.25
25
=IF(L9=1,$Y$4,IF(L9=2,$Y$4*0.9, IF(L9=3,$Y$4*0.8, IF(L9=4,$Y$4*0.7, IF(L9=5,$Y$4*0.6, IF(L9=6,$Y$4*0.5, IF(L9=7,$Y$4*0.4, IF(L9=8,$Y$4*0.3, IF(L9=9,$Y$4*0.2, IF(L9=10,$Y$4*0.1,0))))))))))
DESIRED...
I would like to use a statement to determine three criteria in order to apply a score (1=100, 2=90, 3=80, etc..).
SUM the rank positions of each of the four categories-apply product rank ascending (not including NULL since it's not in the Top 10)
IF a product is identified in more than one metric-apply a significant contribution weight of (*.75),
IF a product has the number 1 rank in any of the four metrics-apply a score of (100).
Data - UPDATED EXAMPLE
(Product) Parts Labor Overhead External Final Score
"XYZ" 3 1 7 7 100
"ABC" NULL 6 NULL 2 100
"LMN" 4 NULL NULL NULL 70
This is way beyond my capability. ANY assistance is appreciated greatly!!!
Jim
I figured this is a good start and I can alter the weight as needed to reflect the reality of the situation.
=AVERAGE(G28:I28)+SUM(G28:I28)*0.25
However, I couldn't figure out how to put a cap on the score of no more than 100 points.
I am still unclear of what exactly you are attempting and if this will work, but how about this simple matrix using an array formula and some conditional formatting.
Array Formula in F2 (make sure to press Ctrl+Shift+Enter when exiting formula edit mode)
=MIN(100,SUM(IF(B2:E2<>"NULL",CHOOSE(B2:E2,100,90,80,70,60,50,40,30,20,10))))
Conditional Formatting defined as shown below.
Red = 100 value where it comes from a 1
Yellow = 100 value where it comes from more than 1 factor, but without a 1.
I want to set a formula that incorporates my school's attendance policy:
3 tardies = 1 unexcused absence
6 tardies = 2 unexcused absences
and so on
The cell must reference not only the cell with the Tardy count, but also the attendance worksheet in the same workbook, and must add the two values. For example, if the attendance page shows 1 unexcused absence and the tardy count shows 7 tardies, the formula needs to return 3.
This is what I've got:
=SUM(Attendance!O9+(IF(J4>=3,1,IF(J4>=6,2,IF(J4>=9,3,IF(J4>=12,4,))))))
It works for 4 tardies and 1 unexcused absence, but continues to return 2 for 7 tardies and 1 unexcused absence.
What am I missing?
Much easier than using If/Then:
=Attendance!O9+(Int(J4/3))
The Int function returns the floor integer of the calculation, J4/3. So, if J4 = 7, the result is 2. If J4=9, the result is 3, etc.
Your if statements are backwards you should check for bigger numbers first in this case otherwise the first if is always true. so 7 is falling true on >= 3 therefore you get 1 + 1 = 2
EDIT - a better way to do it would be to take your J4 divide it by 3 and return the value without the remainder
QUOTIENT(J4, 3)
The if part of your formula should be as follows
IF(J4<3,0,(IF(J4<6,1,(IF(J4<9,2,IF(J4<12,3,4))))))
Bear in mind that this formulae limits you to a maximum of 4 unexcused absences for tardies.
A better solution would be to use the QUOTIENT formula
= Attendance!O9 + QUOTIENT(J4,3)