Nested IF statements

anmillin

New Member
Joined
Mar 14, 2016
Messages
3
Hoping for some help with nested IF statements!

In the example below, I'm trying to calculate pricing for a range of products across different stocking units (pack sizes). There are multiple products against which I'm trying to apply a standard differential of:

AAA= CCC-$12
BBB= CCC-$5
CCC= reference price
DDD= CCC+$8

Excel%20snip_zpsj4otwrg4.jpg
[/URL][/IMG]


So, if Column A=Column B and Pack Code = CCC, no change in price. If Column A=Column B and Pack code=DDD, the value should be Pack code CCC for that product + $8 etc. for all different products and pack codes.

Can this be done and if so, can you guide me on how?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
CCC is the only price - it maybe worth putting that into a cell as reference - so you can change that - Lets assume its in cell Z1 as 150

=IF( AND( A2=B2, C2 = "CCC" ) , $Z$1, IF( AND(A2=B2, C2 = "AAA" ), $Z$1 -12 , IF( AND(A2=B2, C2 = "BBB" ) , $Z$1 -5, IF( AND(A2=B2, C2 = "DDD" ) , $Z$1 + 8 , "criteria NOT met" ))))

if you want to hardcode the value into the nested IF then change $Z$1 in the formula to 150
 
Last edited:
Upvote 0
CCC is the only price - it maybe worth putting that into a cell as reference - so you can change that - Lets assume its in cell Z1 as 150

=IF( AND( A2=B2, C2 = "CCC" ) , $Z$1, IF( AND(A2=B2, C2 = "AAA" ), $Z$1 -12 , IF( AND(A2=B2, C2 = "BBB" ) , $Z$1 -5, IF( AND(A2=B2, C2 = "DDD" ) , $Z$1 + 8 , "criteria NOT met" ))))

if you want to hardcode the value into the nested IF then change $Z$1 in the formula to 150

Thanks for the reply etaf. With regards to the reference cell Z1, will the formula still work with various values for CCC pack codes?

In the example, every product has a different price for CCC-can I calculate the other prices with a variable CCC value for each product?
 
Upvote 0
sorry , i dont understand the question

you showed 4 packs and the formula calculates the 4 values based on the info provided
AAA= CCC-$12
BBB= CCC-$5
CCC= reference price
DDD= CCC+$8

and the Nested IF will work for those 4 packs and values as defined
However, if they are changing - then we can use a reference table to lookup all the differences for each pack

so in sheet2
if you had

AAA / -12
BBB / - 5
CCC / 0
DDD / +8

you can add more packs
although if you so this then you could include the actual value

in say sheet2 A1 = put the reference
then in the table you could add an extra column with the absolute value

A1 = 150
AAA / -12 / B2-$A$1
BBB / - 5 / B3-$A$1
CCC / 0 / B4-$A$1
DDD / +8 / B5-$A$1

Now all you need is a lookup

=index ( Sheet2!C:C, match( C2 , sheet2!A:A, 0 ))

with the IF to get if A2=B2

=IF( A2=B2,
index ( Sheet2!C:C, match( C2 , sheet2!A:A, 0 )) , "Criteria NOT met" )


 
Last edited:
Upvote 0
Hi,

Perhaps you can set your table up like this:


Excel 2010
ABCDEFGHIJ
1Product CodeProduct CodePack CodeDescriptionPriceProductProduct PriceProduct CodePrice Adjustment
2Product1AAAProduct1AAAAAAProduct 1138Product 1150AAA($12)
3Product1BBBProduct1BBBBBBProduct 1145Product 2155BBB($5)
4Product1CCCProduct1CCCCCCProduct 1150Product 3160CCC0
5Product1DDDProduct1DDDDDDProduct 1158DDD$8
6Product2AAAProduct2AAAAAAProduct 2143
7Product2BBBProduct2BBBBBBProduct 2150
8Product2CCCProduct2CCCCCCProduct 2155
9Product2DDDProduct2DDDDDDProduct 2163
10Product3AAAProduct3AAAAAAProduct 3148
11Product3BBBProduct3BBBBBBProduct 3155
12Product3CCCProduct3CCCCCCProduct 3160
13Product3DDDProduct3DDDDDDProduct 3168
Sheet1
Cell Formulas
RangeFormula
E2=IF(A2=B2,VLOOKUP(D2,G$2:H$4,2)+VLOOKUP(C2,I$2:J$5,2),"")


E2 formula copied down.
 
Upvote 0
sorry , i dont understand the question

you showed 4 packs and the formula calculates the 4 values based on the info provided
AAA= CCC-$12
BBB= CCC-$5
CCC= reference price
DDD= CCC+$8

and the Nested IF will work for those 4 packs and values as defined
However, if they are changing - then we can use a reference table to lookup all the differences for each pack

so in sheet2
if you had

AAA / -12
BBB / - 5
CCC / 0
DDD / +8

you can add more packs
although if you so this then you could include the actual value

in say sheet2 A1 = put the reference
then in the table you could add an extra column with the absolute value

A1 = 150
AAA / -12 / B2-$A$1
BBB / - 5 / B3-$A$1
CCC / 0 / B4-$A$1
DDD / +8 / B5-$A$1

Now all you need is a lookup

=index ( Sheet2!C:C, match( C2 , sheet2!A:A, 0 ))

with the IF to get if A2=B2

=IF( A2=B2,
index ( Sheet2!C:C, match( C2 , sheet2!A:A, 0 )) , "Criteria NOT met" )



Sorry etaf, I didn't explain very well. As I understand, you're calculation will work if the price is constant for pack size CCC for every product. My issue is that CCC price is different for every product. It wouldn't be possible to have a reference price as it's variable.
 
Upvote 0
confused
you said CCC was a reference of 150
and so thats what is used to get the values for AAA, BBB, DDD

but if the CCC price changes in the future from 150 - then having to change formulas where its hardcoded - buy having the 150 in one cell, all you need to do is to change that one cell to the new reference price and all the other values will now changed based on the new reference value of CCC
 
Upvote 0
Have you checked out my post #5??? Goodnight.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,365
Messages
6,136,120
Members
449,993
Latest member
Sphere2215

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top