switch function help?

sully343

New Member
Joined
Feb 8, 2018
Messages
3
Hello,

Coming to you guys looking for a little help. I attached the spreadsheet for reference.

The cell I'm working on is F11. It has an equation in it that I need to link to two drop down selection.

About 3/4 of the way through the function is "0.75"

That is a fixed value I put, that I need to make a variable based on the drop down in D3.

I need it to be:
High = 1.25
Medium = 0.90
Low = 0.75

Then lastly, if "yes" is selected in the D4 drop down, the entire equation gets cut in half (divided by 2)...


I was given this code to use in F11, however when I use it it gives me a #NAME ! Error...

Code:
[FONT=arial]IF(D4="Yes",(((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *SWITCH(D3,"Low",0.75,"Medium"[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">[FONT=arial],0.9,"High",1.25))/ 50 )* B4)/2,((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *SWITCH(D3,"Low",0.75,"Medium"[/FONT]<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">[FONT=arial],0.9,"High",1.25))/ 50 )* B4)[/FONT]


Thanks for any help, this is greatly appreciated.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Switch is a function only available in XL2016 with an Office365 subscription
It's basically a shortcut for nesting ifs..

SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25)
It's saying IF D3 = Low, then 0.75, if D3 is Medium, then 0.9, if D3 is High, then 1.25.

You'll have to replace that with
IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25)))
 
Last edited:
Upvote 0
This is all else being equal, assumption that the SWITCH function is the only problem with the formula...

Change both occurrences of
SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25)
to
IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25)))

So original
IF(D4="Yes",(((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25))/ 50 )* B4)/2,((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25))/ 50 )* B4)

change to

IF(D4="Yes",(((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25))))/ 50 )* B4)/2,((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25))))/ 50 )* B4)



Note, there are a lot of spaces in that formula, possibly resulting from your copy paste from excel to forum procedure.
You may need to remove them.
 
Upvote 0
This is all else being equal, assumption that the SWITCH function is the only problem with the formula...

Change both occurrences of
SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25)
to
IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25)))

So original
IF(D4="Yes",(((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25))/ 50 )* B4)/2,((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *SWITCH(D3,"Low",0.75,"Medium"<wbr style="font-family: arial, sans-serif; font-size: 12.8px;">,0.9,"High",1.25))/ 50 )* B4)

change to

IF(D4="Yes",(((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25))))/ 50 )* B4)/2,((((((182.4601 * F2 -775.6821) * F2 +1262.7794) * F2 -669.5622) *10) *IF(D3="Low",0.75,IF(D3="Medium",0.9,IF(D3="High",1.25))))/ 50 )* B4)



Note, there are a lot of spaces in that formula, possibly resulting from your copy paste from excel to forum procedure.
You may need to remove them.


Viola! That worked perfectly. Thank you very much!
 
Upvote 0
Late to the party, but I would suggest replacing

SWITCH(D3,"Low",0.75,"Medium",0.9,"High",1.25)

with

VLOOKUP(D3,{"Low",0.75;"Medium",0.9;"High",1.25},2,0)

One function call, one reference call, similar syntax, same functionality.
 
Upvote 0
One notable difference is that will result in #N/A if D3 is anything other than one of the 3 values, and the overall result of the formula is also #N/A
Conversely, The IF will result in FALSE (therefore the overall result of the formula is 0 instead of #N/A)

I know the original switch function did the same thing, but it's worth noting, and perhaps that would be an improvement.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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