How to narrow this formula down?

albertc30

Well-known Member
Joined
May 7, 2012
Messages
1,091
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone.

It has been quite sometime since I was last here, but with becoming a father in recent years and starting a family, time is realy scarce.

Anyways, I hope that this post finds all members, old and new, in good health and in good spirits.

Now, down to the question. I have this working so this is not of much importance. However, as I have always been very impressed with some brilliant minds in here, how would one shorthen this formula?

=IF(OR(E25="",E25="No"),,IF(AND(D25="Saturday",E25="Yes"),50,IF(AND(D25="Saturday",E25="Yes/On-Call"),95,IF(AND(D25="Sunday",E25="Yes/On-Call"),95,IF(AND(D25="Saturday",E25="On-Call"),45,IF(AND(D25="Sunday",E25="On-Call"),45,IF(AND(D25="Monday",E25="Yes/On-Call"),179.64,IF(AND(D25="Tuesday",E25="Yes/On-Call"),179.64,IF(AND(D25="Wednesday",E25="Yes/On-Call"),179.64,IF(AND(D25="Thursday",E25="Yes/On-Call"),179.64,IF(AND(D25="Friday",E25="Yes/On-Call"),179.64,134.64)))))))))))

Like I said, this is working but I am positive there's a better and shorter version to achieve the same result and I have busted my mind but the above is all I could come up with.

Once again, this is not of any importance and the formula is working as intended. For all of you out there, a much big thanks for all the help you have offered me in the past and for all you current help and generosity in giving your precious time into trying and helping other, something I hope to do too in the not so distante future.

Much appreciated for everything.

Regards,
Albert
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The way I would have done it is put down a table of the value like Yes, Yes/On-call, On-call, No. and the lines being the day of the week.
In the cross between Saturday/Yes it would be 50, Saturday/No 0, etc
Advantage being it's much easier to edit if you want to change pricing and it's more visual too.

Then you can use Match to find the line number and column number the info provided in D25/E25 is refering to and put these into an Index.

So let's say the table is in A1 to E8 and Day you input is still in D25, the service provided is in E25 still;
=index(B2:D8,match(D25,A2:A8,0),match(E25,B1:E1,0))

You may still want to add something to catch an empty field, especially if you want to charge 134.64 if the day is filled but no service info was given...
But that's my idea of how I would handle it. That's why excel is sometimes to fun, you can do it so many ways :)

Simon
 
Upvote 0
The way I would have done it is put down a table of the value like Yes, Yes/On-call, On-call, No. and the lines being the day of the week.
In the cross between Saturday/Yes it would be 50, Saturday/No 0, etc
Advantage being it's much easier to edit if you want to change pricing and it's more visual too.

Then you can use Match to find the line number and column number the info provided in D25/E25 is refering to and put these into an Index.

So let's say the table is in A1 to E8 and Day you input is still in D25, the service provided is in E25 still;
=index(B2:D8,match(D25,A2:A8,0),match(E25,B1:E1,0))

You may still want to add something to catch an empty field, especially if you want to charge 134.64 if the day is filled but no service info was given...
But that's my idea of how I would handle it. That's why excel is sometimes to fun, you can do it so many ways :)

Simon
Oh Simon! LOL...

Now that you mention it, it makes so much more sense!

The various ways to have fun on excel!!!

Thank you for your imput Simon. It is much appreciated.

Regards,
Albert
 
Upvote 0
When is 134.64 applicable?
Two alternatives that you can try or you can look at Index / Match.
The two criteria are concatenated for example =D4&E4 in order to simplify the lookup.

T202211a.xlsm
ABCDEFG
1
2134.64134.64
3
4SaturdayYesSaturdayYes50.00
5SaturdayOn-callSaturdayOn-call45.00
6SundayYes/On-callSundayYes/On-call95.00
7SundayOn-callSundayOn-call45.00
8MondayYes/On-callMondayYes/On-call179.64
9TuesdayYes/On-callTuesdayYes/On-call179.64
10WednesdayYes/On-callWednesdayYes/On-call179.64
11ThursdayYes/On-callThursdayYes/On-call179.64
12FridayYes/On-callFridayYes/On-call179.64
13YesYes134.64
14
9g
Cell Formulas
RangeFormula
B2B2=IF(OR(E25={"","No"}),"",IF(AND(D25="Saturday",E25="Yes"),50,IF(AND(OR(D25={"Saturday","Sunday"}),E25="Yes/On-Call"),95,IF(AND(OR(D25={"Saturday","Sunday"}),E25="On-Call"),45,IF(AND(OR(D25={"Monday","Tuesday","Wednesday","Thursday","Friday"}),E25="Yes/On-Call"),179.64,134.64)))))
C2C2=VLOOKUP(D25&E25,F4:G13,2,0)
 
Last edited:
Upvote 0
When is 134.64 applicable?
Two alternatives that you can try or you can look at Index / Match.
The two criteria are concatenated for example =D4&E4 in order to simplify the lookup.

T202211a.xlsm
ABCDEFG
1
2134.64134.64
3
4SaturdayYesSaturdayYes50.00
5SaturdayOn-callSaturdayOn-call45.00
6SundayYes/On-callSundayYes/On-call95.00
7SundayOn-callSundayOn-call45.00
8MondayYes/On-callMondayYes/On-call179.64
9TuesdayYes/On-callTuesdayYes/On-call179.64
10WednesdayYes/On-callWednesdayYes/On-call179.64
11ThursdayYes/On-callThursdayYes/On-call179.64
12FridayYes/On-callFridayYes/On-call179.64
13YesYes134.64
14
9g
Cell Formulas
RangeFormula
B2B2=IF(OR(E25={"","No"}),"",IF(AND(D25="Saturday",E25="Yes"),50,IF(AND(OR(D25={"Saturday","Sunday"}),E25="Yes/On-Call"),95,IF(AND(OR(D25={"Saturday","Sunday"}),E25="On-Call"),45,IF(AND(OR(D25={"Monday","Tuesday","Wednesday","Thursday","Friday"}),E25="Yes/On-Call"),179.64,134.64)))))
C2C2=VLOOKUP(D25&E25,F4:G13,2,0)
Hi Dave.

Sorry for the delay.

That sounds a great aproach. I can see that ebing much better. But I must admit I never played around with Index much let alone Match. I will give it a go.

Much appreciated for your reply and thanks for helping.

Have a good weekend everyone.

Regards,
Albert
 
Upvote 0
If your concern is using the table, the table is not required if you name the array of lookup information.

Name the information with Formulas Name Manager.

You can just enter the information or move to cell C2 in my example, highlight F4:G15 and press key F9, and select the information.

In Name Manager
Name aL
Value ={"",0;"No",0;"SaturdayYes",50;"SaturdayOn-call",45;"SundayYes/On-call",95;"SundayOn-call",45;"MondayYes/On-call",179.64;"TuesdayYes/On-call",179.64;"WednesdayYes/On-call",179.64;"ThursdayYes/On-call",179.64;"FridayYes/On-call",179.64;"Yes",134.64}

T202211a.xlsm
ABCDEFG
1
2179.64179.64179.64
3
40
5NoNo0
6SaturdayYesSaturdayYes50.00
7SaturdayOn-callSaturdayOn-call45.00
8SundayYes/On-callSundayYes/On-call95.00
9SundayOn-callSundayOn-call45.00
10MondayYes/On-callMondayYes/On-call179.64
11TuesdayYes/On-callTuesdayYes/On-call179.64
12WednesdayYes/On-callWednesdayYes/On-call179.64
13ThursdayYes/On-callThursdayYes/On-call179.64
14FridayYes/On-callFridayYes/On-call179.64
15YesYes134.64
16
9g
Cell Formulas
RangeFormula
B2B2=IF(OR(E25={"","No"}),"",IF(AND(D25="Saturday",E25="Yes"),50,IF(AND(OR(D25={"Saturday","Sunday"}),E25="Yes/On-Call"),95,IF(AND(OR(D25={"Saturday","Sunday"}),E25="On-Call"),45,IF(AND(OR(D25={"Monday","Tuesday","Wednesday","Thursday","Friday"}),E25="Yes/On-Call"),179.64,134.64)))))
C2C2=VLOOKUP(D25&E25,F4:G15,2,0)
D2D2=VLOOKUP(D25&E25,aL,2,0)
 
Upvote 0
T202211a.xlsm
DEF
27SundayOn-call45
9g
Cell Formulas
RangeFormula
F27F27=VLOOKUP(D27&E27,aL,2,0)
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,317
Members
449,218
Latest member
Excel Master

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