Can this formula be simplified?

Drew Terp

New Member
Joined
Apr 12, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
=IF(($C$6-C29)>400,4,IF(($C$6-C29)>350,3.5,IF(($C$6-C29)>300,3,IF(($C$6-C29)>250,2.5,IF(($C$6-C29)>200,2,IF(($C$6-C29)>100,1.5,IF(($C$6-C29)>50,1,0.5)))))))

I'm creating a worksheet to assist my chefs in their fish order. C6 refers to how many reservations we have that evening. C29 is the amount of reservations that are parties (they don't count toward total reservations for ordering fish - yes, I could pull this aside to simplify). Each breakdown is checking the amount of reservations minus parties, and then suggesting a set amount of cases of fish to order. Is there an easier way to go about this?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Give this a try:

Excel Formula:
=LOOKUP($C$6-C29,{0,51,101,201,251,301,351,401},{0.5,1,1.5,2,2.5,3,3.5,4})
 
Upvote 0
=LOOKUP($C$6-C29,{0,51,101,201,251,301,351,401},{0.5,1,1.5,2,2.5,3,3.5,4})
When I plugged it in, it returned a value of 4 instead of the desired value of 2.5.
 

Attachments

  • Screenshot 2024-04-15 201714.png
    Screenshot 2024-04-15 201714.png
    53.1 KB · Views: 7
  • Screenshot 2024-04-15 201904.png
    Screenshot 2024-04-15 201904.png
    52.2 KB · Views: 7
Upvote 0
What data is in C6 and C29 to get the result of 2.5 ??
IF C6 = 424 and c29 = 19 then that gives you 405 which will return 4 ???
Also, when using the IF formula in this case, you should always start at the lowest value and work up,not the other way round.
In your example formula, if the value was greater than 400, then all cases of the formula would be true !!
 
Upvote 0
How about:
Excel Formula:
=IF($C$6-C29>450,4,FLOOR(($C$6-C29)/100-0.0001,0.5))
which can also be done this way:
Excel Formula:
=LET(diff,$C$6-C29,IF(diff>450,4,FLOOR((diff)/100-0.0001,0.5)))
 
Upvote 0
Solution
What data is in C6 and C29 to get the result of 2.5 ??
IF C6 = 424 and c29 = 19 then that gives you 405 which will return 4 ???
Also, when using the IF formula in this case, you should always start at the lowest value and work up,not the other way round.
In your example formula, if the value was greater than 400, then all cases of the formula would be true !!
I posted the original formula where the balance against was C29, but when I reposted with the screen shot I had moved the values to C10. C6=424, and C10=127, then the value comes back as 2.5.

I haven't had any issues with returning multiple values for anything working down the formula, but I see the wisdom in starting lowest and going to highest.
 
Upvote 0
How about:
Excel Formula:
=IF($C$6-C29>450,4,FLOOR(($C$6-C29)/100-0.0001,0.5))
which can also be done this way:
Excel Formula:
=LET(diff,$C$6-C29,IF(diff>450,4,FLOOR((diff)/100-0.0001,0.5)))
These are both great! Thank you! Where can I go to learn why this works? I'd like to be able to understand and not just utilize it.
 
Upvote 0
If you use the Formula Tab and select Evaluate formula. You can step through the formula one step ata time and see how it works.
 
Upvote 1
This will shorten Alex's formula a bit more:

Excel Formula:
=MIN(4,FLOOR(($C$6-C29)/100-0.0001,0.5))

Both Alex's idea, and the trick I just suggested, are both the result of lots of experience and experimentation, and seeing how others solve problems. Like Michael said, try running the formula through the Evaluate Formula tool, with different input values.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

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