Need a book order formula which counts all students but results in zero if no textbook is needed

djaida

Board Regular
Joined
Apr 27, 2022
Messages
59
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hello all,

I hope the thread title makes it clear what kind of formula I need. I'm trying to develop a spreadsheet for book orders. I have a list of courses and accompanying textbooks for which I need quantities for major courses all students attend together, and minor courses that they attend separately. I have a separate list of students and which major and minor courses they have chosen.

My quantity uses a countif formula to count how many copies of major and minor course textbooks I will need:

Major courses in Column F of the students list:
Excel Formula:
=COUNTIF($F$20:$F$42;"Computer Science")
Minor coursesin Column G of the students list:
Excel Formula:
=COUNTIF($G$20:$G$42;"Business")

then another one which adds up the quantity with an additional copy for the instructor and subtracts any copies we already have in stock:

To order (quantity + instructor copy - in stock):
Excel Formula:
=IF(I5+J5-K5<0;0;I5+J5-K5)

How do I edit the countif formula to result in 0 when an instructor decides they will use other materials instead of a set textbook? Or is there another formula which is better suited to what I need? Thank you in advance!
 
no, sorry - i looked at yesterday and not really understanding what you are doing, and thought it was now solved
i will have another look over the next couple of days and see if i can understand ,
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
still not following - sorry
can you make the data much shorter - maybe 20 rows or more if needed to show whats needed
i can make out the following

How the list form row 16
matches with row 8 data
why computer science hard coded
now counting the year - ok

i suspect its just a case of counting the correct columns
you can add 2 countif() together

countif( major and year) + countif ( minor and year )
but you would needed to also add the course - so maybe needed a countis()
 
Upvote 0
still not following - sorry
can you make the data much shorter - maybe 20 rows or more if needed to show whats needed
i can make out the following

How the list form row 16
matches with row 8 data
why computer science hard coded
now counting the year - ok

i suspect its just a case of counting the correct columns
you can add 2 countif() together

countif( major and year) + countif ( minor and year )
but you would needed to also add the course - so maybe needed a countis()
Hi, thank you; I will try adding two together - I'm still learning this level of formulas. I will have to look up counties as I never used it before.

I will try to adapt the table today and post it so it can be worked on. I have separated the data into another sheet, would that matter or should I put it back on the main sheet?
 
Upvote 0
fine on a 2nd sheet - just post xl2bb or share the file
countifs() - using more than 1 criteria
so you can
=countifs( range of year , year , range of major , major) + countifs( range of year , year , range of minor , minor)
 
Upvote 0
fine on a 2nd sheet - just post xl2bb or share the file
countifs() - using more than 1 criteria
so you can
=countifs( range of year , year , range of major , major) + countifs( range of year , year , range of minor , minor)
Alright, let me see if I can explain what I am trying to do, and then I can anonymize the data and share it.

For each department in a given semester I get a list of students, courses and textbooks they will use for those courses. I need to order enough textbooks to cover all students. Some textbooks are ordered directly through the publisher, for others I need to receive price quotes from suppliers. This information needs to be separated into Publisher 1, Publisher 2, and Quote sheets. I've got that part solved.

The shared table shows only CS department years 1 through 4, but the next department (Economics) would be listed starting with Year 1 right below the CS Year 4. After that I would have Political Science and on, until I had all the departments listed. This is because I need to know the price of the single student package by department and year, and the total price of all copies in a year and department.

The quantities for each course currently need to be entered manually by checking how many students are attending which common courses and minor courses. I would like formulas to do the following:

- if there is no textbook in column F, fill the cell in column J with 0 (I've got that part solved)
- if there is no lecturer in column E, fill the cell in column K with 0 (I've got that part solved)
- if there is a textbook in column F, fill in the necessary quantity in column J based on the major, minor, and year columns in the data sheet (years 1 and 2 have no minors, while years 3 and 4 do)
- if there is a lecturer in column E, add an additional copy in cell K (I've got that part solved)
- in the TO ORDER column M add quantity and instructor copies, and subtract in stock copies (I've got that part solved)

When it comes to prices, I already have these formulas:
- MAX formula to get the Price final recorded in the direct order columns
- INDEX and MATCH formulas to get the Supplier final based on the Price final and direct order vs local supplier named ranges
- IF and ISBLANK formulas which determine where a UNIQUE filter will separate the information: in two publisher sheets or the quote needed sheet.
The problem is that if there's no textbook, IF and ISBLANK still records that as quote needed, while the quantity is zero. I suppose I could copy & paste that information as values and manually delete the zero quantity lines, but is there a way for the formula to recognize that 0 textbook also means 0 quote needed?

I basically want a workbook where the only information I will need to enter manually would be the quantities we already have in stock, and the prices we receive from the publishers and suppliers. Everything else I want the formulas to pick up from already existing data - list of all students grouped by year, major, minor; list of courses and their lecturers and textbooks (this part I have no idea how to do; I have a vague idea that it may be done with pivot tables, which I know nothing about).

ORDER CALCULATIONS ANONYMIZED.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
5 FOREIGN SUPPLIERS LOCAL SUPPLIERS
6 DIRECT ORDERS
7YearCodeTitleLecturerTextbookAuthorPublisherISBNQuantityInstructorIn stockTO ORDERCENGAGEPEARSONSUPPLIER1SUPPLIER2SUPPLIER3QUOTESupplier FinalPrice finalAvailabilityTrackingCOSTARRIVED #
81CS121Computer Organization and ArchitectureName SurnameComputer Organization and ArchitectureMcGraw-Hill5106$ 40.00$ 50.001SUPPLIER2$ 40.00Pending$ 240.00
91CS122Programming and Problem Solving IIName SurnameProgramming and Problem Solving IIPearson51170$ 50.000PEARSON$ 50.00Pending$ -
101Math123Discrete MathematicsName SurnameDiscrete MathematicsPearson51160$ 50.000PEARSON$ 50.00Pending$ -
112CS221Database SystemsName SurnameDatabase SystemsCENGAGE5106$ 50.000CENGAGE$ 50.00Pending$ 300.00
122CS222Operating SystemsName SurnameOperating SystemsWiley5106$ 50.00$ 40.001SUPPLIER3$ 40.00Pending$ 240.00
132CS223Cloud ComputingName SurnameCloud ComputingPearson5106$ 50.000PEARSON$ 50.00Pending$ 300.00
142CS224Design and Implementation in Web EnvironmentsName SurnameDesign and Implementation in Web EnvironmentsPearson5106$ 50.000PEARSON$ 50.00Pending$ 300.00
152CS225Design and Implementation in Web EnvironmentsName SurnameDesign and Implementation in Web EnvironmentsPearson5106$ 50.000PEARSON$ 50.00Pending$ 300.00
16Common courses3CS321Project managementName SurnameProject managementProject Management Institute5106$ 40.00$ 50.001SUPPLIER2$ 40.00Pending$ 240.00
173CS322Business IntelligenceName SurnameBusiness IntelligencePearson51170$ 50.000PEARSON$ 50.00Pending$ -
183CS323Software EngineeringName SurnameSoftware EngineeringPearson51160$ 50.000PEARSON$ 50.00Pending$ -
193ENG324Reports and Professional CorrespondenceName Surname00001#N/A$ -Pending$ -
20Electrical Engineering3EE325Electrical EngineeringElectrical EngineeringWiley – IEEE Press5005$ 50.00$ 40.001SUPPLIER3$ 40.00Pending$ 200.00
21Business3EC326Marketing fundamentals00001#N/A$ -Pending$ -
22Economics3EC327Introduction to MacroecenomicsName SurnameIntroduction to MacroecenomicsPearson3104$ 50.000PEARSON$ 50.00Pending$ 200.00
23Common courses4CS421Applied ProgrammingName SurnameApplied ProgrammingPearson5106$ 50.000PEARSON$ 50.00Pending$ 300.00
244CS422Embedded SystemsName SurnameEmbedded SystemsSpringer 51170$ 40.00$ 50.001SUPPLIER2$ 40.00Pending$ -
254CS423Dissertation Research and WritingName SurnameDissertation Research and WritingRed Globe Press / Macmillan51160$ 50.00$ 40.001SUPPLIER3$ 40.00Pending$ -
26Electrical Engineering4EE425Multimedia ElectronicsName SurnameMultimedia ElectronicsPearson2103$ 50.000PEARSON$ 50.00Pending$ 150.00
274EE426Selected topics in engineeringName SurnameSelected topics in engineeringWiley – IEEE Press2103$ 40.00$ 50.001SUPPLIER2$ 40.00Pending$ 120.00
28Business4EC427Corporate Strategy and Strategic ManagementName SurnameCorporate Strategy and Strategic ManagementCENGAGE2103$ 50.000CENGAGE$ 50.00Pending$ 150.00
294EC428Introduction to financeName SurnameIntroduction to financePearson2103$ 50.000PEARSON$ 50.00Pending$ 150.00
30Economics4EC429Corporate Social ResponsibilityName SurnameCorporate Social ResponsibilityPearson1102$ 50.000PEARSON$ 50.00Pending$ 100.00
Listing
Cell Formulas
RangeFormula
J8:J10J8=IF(F8="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"-",Data!$H:$H,"1")))
K8:K30K8=IF(F8="",0,COUNTIF(E8,"<>"))
J11:J15J11=IF(F11="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"-",Data!$H:$H,"2")))
J16:J20J16=IF(F16="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$H:$H,"3")))
J21J21=IF(F21="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"Business",Data!$H:$H,"3")))
J22J22=IF(F22="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"Economics",Data!$H:$H,"3")))
J23:J25J23=IF(F23="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$H:$H,"4")))
J26:J27J26=IF(F26="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"Electronic and Electrical Engineering",Data!$H:$H,"4")))
J28:J29J28=IF(F28="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"Business",Data!$H:$H,"4")))
J30J30=IF(F30="",0,(COUNTIFS(Data!$F:$F,"Computer Science",Data!$G:$G,"Economics",Data!$H:$H,"4")))
S8:S30S8=IF(AND(ISBLANK(N8), ISBLANK(O8),ISBLANK(P8)),1, 0)
T8,T12,T16,T19:T20,T24:T25,T27T8=INDEX(local_suppliers,MATCH(U8,Q8:R8,0))
U8,U12,U16,U19:U20,U24:U25,U27U8=MIN(Q8:R8)
T9:T11,T13:T15,T17:T18,T21:T23,T26,T28:T30T9=INDEX(direct_orders,MATCH(U9,N9:P9,0))
U9:U11,U13:U15,U17:U18,U21:U23,U26,U28:U30U9=MAX(N9:P9)
M8:M30M8=IF(J8+K8-L8<0,0,J8+K8-L8)
X8:X30X8=M8*U8
Named Ranges
NameRefers ToCells
direct_orders=Listing!$N$7:$P$7T26, T9:T11, T17:T18, T21:T23, T28:T30, T13:T15
local_suppliers=Listing!$Q$7:$R$7T27, T16, T12, T8, T24:T25, T19:T20
Cells with Conditional Formatting
CellConditionCell FormatStop If True
Q27:R27Other TypeColor scaleNO
Q25:R25Other TypeColor scaleNO
Q24:R24Other TypeColor scaleNO
Q20:R20Other TypeColor scaleNO
Q16:R16Other TypeColor scaleNO
Q12:R12Other TypeColor scaleNO
Q8:R8Other TypeColor scaleNO
Q26:R26Expression=$F26:$F48=""textNO
Q26:R26Expression=$V26="Available"textNO
Q26:R26Expression=$V26="Temporarily unavailable"textNO
Q26:R26Expression=$V26="Print on demand"textNO
Q26:R26Expression=$V26="Out of print"textNO
Q26:R26Expression=$W26="Ordered"textNO
Q26:R26Expression=$W26="Arrived"textNO
Q26:R26Expression=$W26="Incomplete"textNO
Q26:R26Expression=$W26="Late"textNO
M8:M30,X8:X30,J8:J30Cell Value=0textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$F8:$F30=""textNO
H8:H30,T8:T30Cell Valuecontains "CENGAGE"textNO
H8:H30,T8:T30Cell Valuecontains "PEARSON"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$V8="Available"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$V8="Temporarily unavailable"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$V8="Print on demand"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$V8="Out of print"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$W8="Ordered"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$W8="Arrived"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$W8="Incomplete"textNO
B9:Y11,B8:P8,S8:Y8,B12:P12,S12:Y12,B16:P16,S16:Y16,B20:P20,S20:Y20,B24:P27,B21:Y23,B28:Y30,B13:Y15,S24:Y27,B17:Y19Expression=$W8="Late"textNO
Cells with Data Validation
CellAllowCriteria
V8:V30List=Data!$S$3:$S$6
W8:W30List=Data!$S$9:$S$13
 
Upvote 0
fine on a 2nd sheet - just post xl2bb or share the file
countifs() - using more than 1 criteria
so you can
=countifs( range of year , year , range of major , major) + countifs( range of year , year , range of minor , minor)
Hello, I thought I should also link the full document so it's easier to see what I'm trying to do. I've uploaded the file to Google Drive.

I tried implementing the two countifs but I didn't quite manage, so I reverted to the old formulas. I'm not sure I understood it correctly - how would it look when applied to my sheet??
 
Upvote 0
i need access - so it needs to be shared for everyone
 
Upvote 0
i need access - so it needs to be shared for everyone
Hello, just to check if you had a chance to look at the linked workbook? If not, thank you for your help so far, and I'll continue looking further for the parts that still need answers.
 
Upvote 0
sorry, been really busy sorting out issues at home with leaks and plumbing - not had a chance to look at the full details
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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