Combining MAX IF and MIN IF functions

djaida

Board Regular
Joined
Apr 27, 2022
Messages
59
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I'm working on what to me is a complicated workbook with many formulas that depend on different criteria. I found that I will have to break down my questions and focus on one thing at a time.

Below is the table; it shows two columns which contain two direct order publishers, and two columns with local suppliers that compete for publishers that are not direct order:

Book1
ABCDEFGHIJKLMNOPQRSTUVWX
1 FOREIGN SUPPLIERS LOCAL SUPPLIERS
2 DIRECT ORDER
3YearCodeTitleMinorLecturerTextbookAuthorPublisherISBNQuantityInstructorIn stockTO ORDERCENGAGEPEARSONSUPPLIER1SUPPLIER2QUOTESupplier FinalPrice finalAvailabilityTrackingCOSTARRIVED #
41CS121Computer Organization and ArchitectureName SurnameComputer Organization and ArchitectureMcGraw-Hill5106$ 40,00$ 50,001SUPPLIER1$ 40,00$ 240,00
51CS122Programming and Problem Solving IIName SurnameProgramming and Problem Solving IIPearson5106$ 50,000PEARSON$ 50,00$ 300,00
61CS123Discrete MathematicsName SurnameDiscrete MathematicsCENGAGE5106$ 60,000CENGAGE$ 60,00$ 360,00
71CS124Discrete MathematicsName SurnameDiscrete MathematicsCENGAGE51100$ 60,000#N/A$ -$ -
81CS124Discrete MathematicsName SurnameDiscrete MathematicsWiley5106$ 50,00$ 40,001SUPPLIER2$ 40,00$ 240,00
Sheet2
Cell Formulas
RangeFormula
J4:J8J4=IF(F4="No textbook",0,(COUNTIFS('ORDER CALCULATIONS MINOR COLUMNS.xlsx'!Table1[Major],"Computer Science",'ORDER CALCULATIONS MINOR COLUMNS.xlsx'!Table1[Minor],"-",'ORDER CALCULATIONS MINOR COLUMNS.xlsx'!Table1[Year],"1")))
K4:K8K4=IF(F4="No textbook",0,COUNTIF(E4,"<>"))
R4:R8R4=IF(AND(ISBLANK(N4), ISBLANK(O4)),1, 0)
S4,S8S4=INDEX(local_suppliers,MATCH(T4,P4:Q4,0))
T4,T8T4=MIN(IF(M4<>0,P4:Q4))
S5:S7S5=INDEX(direct_orders,MATCH(T5,N5:O5,0))
T5:T7T5=MAX(IF(M5<>0,N5:O5))
M4:M8M4=IF(J4+K4-L4<0,0,J4+K4-L4)
W4:W8W4=M4*T4
Named Ranges
NameRefers ToCells
direct_orders=Sheet2!$N$3:$O$3S5:S7
local_suppliers=Sheet2!$P$3:$Q$3S8, S4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
S1:S8Cell Valuecontains "SUPPLIER2"textNO
S1:S8Cell Valuecontains "SUPPLIER1"textNO
F1:F8Cell Valuecontains "No textbook"textNO
P4:Q4Other TypeColor scaleNO
J4:J8,M4:M8,W4:W8Cell Value=0textNO
S4:S8,H4:H8Cell Valuecontains "CENGAGE"textNO
H4:H8,S4:S8Cell Valuecontains "PEARSON"textNO
A4:O6,R4:X6,P5:Q6,A7:X8Expression=$U4="Available"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$F4:$F28=""textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$U4="Temporarily unavailable"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$U4="Print on demand"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$U4="Out of print"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$V4="Ordered"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$V4="Arrived"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$V4="Incomplete"textNO
A4:O4,R4:X6,A5:Q6,A7:X8Expression=$V4="Late"textNO


How do I combine the two MIN IF and MAX IF functions so I don't have to use a separate MIN and MAX every time a criteria changes? Both formulas look into column M to determine if the quantity is more than 0, then in the ranges for direct orders (MAX because only one publisher can offer the price for their book) or local suppliers (MIN because the two suppliers can offer different prices for the same book). I need the result to be the MAX value if there's a price in columns N or O and blanks in columns P and Q, and the MIN value if there are blanks in columns N or O and prices in columns P and Q. Can this be done?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
How about
Excel Formula:
=IF(M4=0,0,MAX(N4:O4,MIN(P4:Q4)))
 
Upvote 0
Solution
How about
Excel Formula:
=IF(M4=0,0,MAX(N4:O4,MIN(P4:Q4)))
It looks like it works! Ok, that's one question solved, I will need to formulate the next. Thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
How about this?:

If more than one supplier has the same low price all will get listed in column S

Libro1
ST
3Supplier FinalPrice final
4PEARSON/SUPPLIER140
5PEARSON50
6CENGAGE60
7 0
8SUPPLIER240
Hoja1
Cell Formulas
RangeFormula
S4:S8S4=IFERROR(TEXTBEFORE(CONCAT(FILTER($N$3:$Q$3,($N4:$Q4=T4)*($N4:$Q4<>""))&"/"),"/",-1),"")
T4:T8T4=MIN(N4:Q4)*(M4<>0)
Named Ranges
NameRefers ToCells
local_suppliers=Hoja1!$P$3:$Q$3S4:S8
 
Upvote 0
How about this?:

If more than one supplier has the same low price all will get listed in column S

Libro1
ST
3Supplier FinalPrice final
4PEARSON/SUPPLIER140
5PEARSON50
6CENGAGE60
7 0
8SUPPLIER240
Hoja1
Cell Formulas
RangeFormula
S4:S8S4=IFERROR(TEXTBEFORE(CONCAT(FILTER($N$3:$Q$3,($N4:$Q4=T4)*($N4:$Q4<>""))&"/"),"/",-1),"")
T4:T8T4=MIN(N4:Q4)*(M4<>0)
Named Ranges
NameRefers ToCells
local_suppliers=Hoja1!$P$3:$Q$3S4:S8

Hi, it won't be possible for a publisher and supplier to offer the same price because we order directly from those two publishers, and local suppliers cannot offer prices for them. They can offer only prices for all other publishers (not listed here, but in the master Excel sheet that I am going to apply all of these solutions to, there are hundreds of rows and many other publishers, for several other departments in the uni bookstore - here I have only used a few examples for the CS department textbooks).

It might be possible for two *suppliers* to offer the same price for a textbook, though in practice there's usually a small difference S1 might offer 50.19 and S2 50.49 depending on what conditions they each get from publishers. In that case the lower value gets recorded; even though the difference is small it is significant if many copies are needed. I will test it on a copy of my worksheet, thank you!
 
Upvote 0
How about this?:

If more than one supplier has the same low price all will get listed in column S

Libro1
ST
3Supplier FinalPrice final
4PEARSON/SUPPLIER140
5PEARSON50
6CENGAGE60
7 0
8SUPPLIER240
Hoja1
Cell Formulas
RangeFormula
S4:S8S4=IFERROR(TEXTBEFORE(CONCAT(FILTER($N$3:$Q$3,($N4:$Q4=T4)*($N4:$Q4<>""))&"/"),"/",-1),"")
T4:T8T4=MIN(N4:Q4)*(M4<>0)
Named Ranges
NameRefers ToCells
local_suppliers=Hoja1!$P$3:$Q$3S4:S8
It looks like the formula you posted in cell S4 works, and it also removes the #N/A reference from cell S6. If I understand it correctly, with this formula I can also delete the two different named ranges?

Also, this could be the answer to the question I asked about combining two INDEX and MATCH functions; is it possible to for you to post this in that thread so I can mark it as an answer there? If not, I assume two replies in the same thread can be marked as answers?
 
Upvote 0
The previous formula will work and always display 1 supplier.
But if you like you could change it to:
Excel Formula:
=IFERROR(FILTER($N$3:$Q$3, ($N4:$Q4 = T4) * ($N4:$Q4 <> "")), "")

If you aren't using the named ranges in any other formula, yes, you can delete them.

I will post this solution in the other thread.

And thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
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