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!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
how will excel know that an instructor does not want to use a textbook , is there a column/cell that is noted in ??
 
Upvote 0
how will excel know that an instructor does not want to use a textbook , is there a column/cell that is noted in ??
Hi, I check in with the instructors to see if there have been any changes in their syllabi re: textbooks and they tell me if the textbooks are the same, have changed, or been replaced with materials they will be preparing. If there's no textbook, I enter zeroes in the textbook, author, publisher, and ISBN columns.
 
Upvote 0
need more info on the data structure , not really explainined the info

BUT you count the textbooks required using
=COUNTIF($F$20:$F$42;"Computer Science")
and
=COUNTIF($G$20:$G$42;"Business")

now you want a zero if no textbook in sylabus
so if you enter zero in the textbook fields - then that would not be counted
as the textbook would be zero and NOT contain "business" or "computer science"

and so return zero

you will need to provide

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
need more info on the data structure , not really explainined the info

BUT you count the textbooks required using
=COUNTIF($F$20:$F$42;"Computer Science")
and
=COUNTIF($G$20:$G$42;"Business")

now you want a zero if no textbook in sylabus
so if you enter zero in the textbook fields - then that would not be counted
as the textbook would be zero and NOT contain "business" or "computer science"

and so return zero

you will need to provide

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
Thank you for the advice - I will need to check if I can do this from my personal computer, as I was trying to solve this while I was still at work. If I don't manage tonight, I will try again at work tomorrow.
 
Upvote 0
ok,
i will not be back on forum till sunday (possibly earlier) but plan is sunday
 
Upvote 0
need more info on the data structure , not really explainined the info

BUT you count the textbooks required using
=COUNTIF($F$20:$F$42;"Computer Science")
and
=COUNTIF($G$20:$G$42;"Business")

now you want a zero if no textbook in sylabus
so if you enter zero in the textbook fields - then that would not be counted
as the textbook would be zero and NOT contain "business" or "computer science"

and so return zero

you will need to provide

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
Close - I count the number of students (based on the major courses and minor courses) for whom I will need to order textbooks by using the countif formula. Hopefully all will be cleared up once the data is shared.

I cannot get the add in to work; Excel keeps blocking it first because of protected view, then once that is disabled it blocks all macros. I will need to share it once I desensitize data and add several other formulas and conditional formatting.
 
Upvote 0
Close - I count the number of students (based on the major courses and minor courses) for whom I will need to order textbooks by using the countif formula. Hopefully all will be cleared up once the data is shared.

I cannot get the add in to work; Excel keeps blocking it first because of protected view, then once that is disabled it blocks all macros. I will need to share it once I desensitize data and add several other formulas and conditional formatting.
I spent a few sleepless hours last night because this kept bugging me, and I think I solved most of it, with the result that my solution also brought into focus other problems I needed to solve. Below is the code - I managed to copy install XL2BB on my work computer. I don't know why my home PC absolutely refused to load it.

The names and numbers are all randomly generated.

ORDER CALCULATIONS.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
5 FOREIGN SUPPLIERS LOCAL SUPPLIERS
6 DIRECT ORDERS
7CodeTitleLecturerTextbookAuthorPublisherISBNQuantityInstructor copyIn stockTo orderCENPEABUYBOOFARQUOTESupplier FinalPrice finalCoursebook availabilityShipment trackingCOST
8Common coursesCS320Project managementJohn DoeProject managementEdwardo PetersCEN9780338976063231024$ 60,000CEN$ 60,00Available$ 1.440,00
9CS330Data ScienceJane DoeData ScienceErasmo WatersPEA9781207342138231177$ 55,000PEA$ 55,00Temporarily unavailable$ 385,00
10CS340Software EngineeringThomas HarrySoftware EngineeringAndres MoonBUY9782275762723231168$ 45,000BUY$ 45,00Out of print$ 360,00
11LANG322PresentationsKate Ryan00001#N/A$ -$ -
12Electrical EngineeringEE321Electrical Engineering00001#N/A$ -$ -
13BusinessEC321MarketingAna JansenMarketingKenneth AtkinsWYL9783059458275231024$ 50,00$ 45,001FAR$ 45,00Ordered$ 1.080,00
14EconomicsEC322MacroeconomicsFrancis GarnettMacroeconomicsJim GallagherTHI9784823047075231024$ 35,00$ 40,001BOO$ 35,00Arrived$ 840,00
15
16SurnameName Student ID Programme MajorMinor YearStatusActions
171ArellanoDustin2268970602083Bachelor Degree ProgrammeComputer ScienceBusiness3Active
182CarsonDex4573270028201Bachelor Degree ProgrammeComputer ScienceBusiness3Active
193CisnerosGillian8516091172652Bachelor Degree ProgrammeComputer ScienceBusiness3Active
204CookeHugh8951820536994Bachelor Degree ProgrammeComputer ScienceEconomics3Active
215CuevasWade5716621426047Bachelor Degree ProgrammeComputer ScienceBusiness3Active
226DanielsJack4857946497807Bachelor Degree ProgrammeComputer ScienceBusiness3Active
237DavidsonHarley3829483244566Bachelor Degree ProgrammeComputer ScienceBusiness3Active
248DonovanGwendolen2723173962826Bachelor Degree ProgrammeComputer ScienceEconomics3Active
259FowlerSullivan9987294165174Bachelor Degree ProgrammeComputer ScienceBusiness3Active
2610FriedmanFrancis3608655008199Bachelor Degree ProgrammeComputer ScienceEconomics3Active
2711GouldEliot5359237907977Bachelor Degree ProgrammeComputer ScienceBusiness3Active
2812HartmanNevin8738017242020Bachelor Degree ProgrammeComputer ScienceBusiness3Active
2913HullMarguerite7011559025579Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3014KleinGrey6814264230181Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3115MahoneyLuther6213008074835Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3216McintoshLillian8969360918961Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3317MontoyaVerena9340112694686Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3418MurilloZachary2836183915869Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3519RyanMeghan4927742034554Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3620SchaeferDrew5448721051560Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3721SpenceMirabel4542903322453Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3822TravisOrrin7469732409758Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3923WashingtonIsaiah7161851494079Bachelor Degree ProgrammeComputer ScienceEconomics3Active
Listing
Cell Formulas
RangeFormula
I8:I14I8=IF(E8="",0,(COUNTIF($F$17:$F$39,"Computer Science")))
J8:J14J8=IF(E8="",0,COUNTIF(D8,"<>"))
R8:R14R8=IF(AND(ISBLANK(M8), ISBLANK(N8),ISBLANK(O8)),1, 0)
S8:S10S8=INDEX(direct_orders,MATCH(T8,M8:O8,0))
T8:T10T8=MAX(M8:O8)
S11:S14S11=INDEX(local_suppliers,MATCH(T11,P11:Q11,0))
T11:T14T11=MIN(P11:Q11)
L8:L14L8=IF(I8+J8-K8<0,0,I8+J8-K8)
W8:W14W8=L8*T8
Named Ranges
NameRefers ToCells
direct_orders=Listing!$M$7:$O$7S8:S10
local_suppliers=Listing!$P$7:$Q$7S11:S14
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B8:V14Expression=$V8="Ordered"textNO
S8:S14Cell Valuecontains "PEA"textNO
S8:S14Cell Valuecontains "CEN"textNO
G8:G14Cell Valuecontains "PEA"textNO
G8:G14Cell Valuecontains "CEN"textNO
B8:U14Expression=$U8="Available"textNO
B8:U14Expression=$U8="Temporarily unavailable"textNO
B8:U14Expression=$U8="Print on demand"textNO
B8:U14Expression=$U8="Out of print"textNO
B8:V14Expression=$V8="Arrived"textNO
B8:V14Expression=$V8="Incomplete"textNO
B8:V14Expression=$V8="Late"textNO
P14:Q14Other TypeColor scaleNO
P13:Q13Other TypeColor scaleNO
B8:X14Expression=$E8=""textNO
Cells with Data Validation
CellAllowCriteria
J17:J39List=Data!$M$2:$M$3
U8:U14List=Data!$O$3:$O$6
V8:V14List=Data!$P$3:$P$7


If any of you have a better solution, please let me know. As you can see, I have a list of students, in this case third year CS. At the end of 2nd year they choose which minors they will study in 3rd and 4th year. I will be getting this data from the registrar.

I will also get data about courses and textbooks from each department. I need to correctly count the number of students in all departments in year for a given academic year and semester, and major/minor combination, separate the list into quote request sheets based on publishers - two of them we order from directly, for the rest we send the quote request to suppliers who provide us with offers. Those are compared, and the suppliers who has a higher number of cheaper titles gets the whole package. Looking at it all I realize I will most likely need to transfer the list of students to another sheet and refer to it from there. All this is probably best done in a database, but I at least have some experience with Excel; I know nothing about databases. And finally, I will need to create charts displaying the number of titles from each publisher and supplier and the cost of those packages, the cost of package for each department, and the status of the orders - whether a book has been ordered, arrived, arrived but incomplete number of copies, or late.
 
Upvote 0
I spent a few sleepless hours last night because this kept bugging me, and I think I solved most of it, with the result that my solution also brought into focus other problems I needed to solve. Below is the code - I managed to copy install XL2BB on my work computer. I don't know why my home PC absolutely refused to load it.

The names and numbers are all randomly generated.

ORDER CALCULATIONS.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
5 FOREIGN SUPPLIERS LOCAL SUPPLIERS
6 DIRECT ORDERS
7CodeTitleLecturerTextbookAuthorPublisherISBNQuantityInstructor copyIn stockTo orderCENPEABUYBOOFARQUOTESupplier FinalPrice finalCoursebook availabilityShipment trackingCOST
8Common coursesCS320Project managementJohn DoeProject managementEdwardo PetersCEN9780338976063231024$ 60,000CEN$ 60,00Available$ 1.440,00
9CS330Data ScienceJane DoeData ScienceErasmo WatersPEA9781207342138231177$ 55,000PEA$ 55,00Temporarily unavailable$ 385,00
10CS340Software EngineeringThomas HarrySoftware EngineeringAndres MoonBUY9782275762723231168$ 45,000BUY$ 45,00Out of print$ 360,00
11LANG322PresentationsKate Ryan00001#N/A$ -$ -
12Electrical EngineeringEE321Electrical Engineering00001#N/A$ -$ -
13BusinessEC321MarketingAna JansenMarketingKenneth AtkinsWYL9783059458275231024$ 50,00$ 45,001FAR$ 45,00Ordered$ 1.080,00
14EconomicsEC322MacroeconomicsFrancis GarnettMacroeconomicsJim GallagherTHI9784823047075231024$ 35,00$ 40,001BOO$ 35,00Arrived$ 840,00
15
16SurnameName Student ID Programme MajorMinor YearStatusActions
171ArellanoDustin2268970602083Bachelor Degree ProgrammeComputer ScienceBusiness3Active
182CarsonDex4573270028201Bachelor Degree ProgrammeComputer ScienceBusiness3Active
193CisnerosGillian8516091172652Bachelor Degree ProgrammeComputer ScienceBusiness3Active
204CookeHugh8951820536994Bachelor Degree ProgrammeComputer ScienceEconomics3Active
215CuevasWade5716621426047Bachelor Degree ProgrammeComputer ScienceBusiness3Active
226DanielsJack4857946497807Bachelor Degree ProgrammeComputer ScienceBusiness3Active
237DavidsonHarley3829483244566Bachelor Degree ProgrammeComputer ScienceBusiness3Active
248DonovanGwendolen2723173962826Bachelor Degree ProgrammeComputer ScienceEconomics3Active
259FowlerSullivan9987294165174Bachelor Degree ProgrammeComputer ScienceBusiness3Active
2610FriedmanFrancis3608655008199Bachelor Degree ProgrammeComputer ScienceEconomics3Active
2711GouldEliot5359237907977Bachelor Degree ProgrammeComputer ScienceBusiness3Active
2812HartmanNevin8738017242020Bachelor Degree ProgrammeComputer ScienceBusiness3Active
2913HullMarguerite7011559025579Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3014KleinGrey6814264230181Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3115MahoneyLuther6213008074835Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3216McintoshLillian8969360918961Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3317MontoyaVerena9340112694686Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3418MurilloZachary2836183915869Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3519RyanMeghan4927742034554Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3620SchaeferDrew5448721051560Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3721SpenceMirabel4542903322453Bachelor Degree ProgrammeComputer ScienceEconomics3Active
3822TravisOrrin7469732409758Bachelor Degree ProgrammeComputer ScienceBusiness3Active
3923WashingtonIsaiah7161851494079Bachelor Degree ProgrammeComputer ScienceEconomics3Active
Listing
Cell Formulas
RangeFormula
I8:I14I8=IF(E8="",0,(COUNTIF($F$17:$F$39,"Computer Science")))
J8:J14J8=IF(E8="",0,COUNTIF(D8,"<>"))
R8:R14R8=IF(AND(ISBLANK(M8), ISBLANK(N8),ISBLANK(O8)),1, 0)
S8:S10S8=INDEX(direct_orders,MATCH(T8,M8:O8,0))
T8:T10T8=MAX(M8:O8)
S11:S14S11=INDEX(local_suppliers,MATCH(T11,P11:Q11,0))
T11:T14T11=MIN(P11:Q11)
L8:L14L8=IF(I8+J8-K8<0,0,I8+J8-K8)
W8:W14W8=L8*T8
Named Ranges
NameRefers ToCells
direct_orders=Listing!$M$7:$O$7S8:S10
local_suppliers=Listing!$P$7:$Q$7S11:S14
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B8:V14Expression=$V8="Ordered"textNO
S8:S14Cell Valuecontains "PEA"textNO
S8:S14Cell Valuecontains "CEN"textNO
G8:G14Cell Valuecontains "PEA"textNO
G8:G14Cell Valuecontains "CEN"textNO
B8:U14Expression=$U8="Available"textNO
B8:U14Expression=$U8="Temporarily unavailable"textNO
B8:U14Expression=$U8="Print on demand"textNO
B8:U14Expression=$U8="Out of print"textNO
B8:V14Expression=$V8="Arrived"textNO
B8:V14Expression=$V8="Incomplete"textNO
B8:V14Expression=$V8="Late"textNO
P14:Q14Other TypeColor scaleNO
P13:Q13Other TypeColor scaleNO
B8:X14Expression=$E8=""textNO
Cells with Data Validation
CellAllowCriteria
J17:J39List=Data!$M$2:$M$3
U8:U14List=Data!$O$3:$O$6
V8:V14List=Data!$P$3:$P$7


If any of you have a better solution, please let me know. As you can see, I have a list of students, in this case third year CS. At the end of 2nd year they choose which minors they will study in 3rd and 4th year. I will be getting this data from the registrar.

I will also get data about courses and textbooks from each department. I need to correctly count the number of students in all departments in year for a given academic year and semester, and major/minor combination, separate the list into quote request sheets based on publishers - two of them we order from directly, for the rest we send the quote request to suppliers who provide us with offers. Those are compared, and the suppliers who has a higher number of cheaper titles gets the whole package. Looking at it all I realize I will most likely need to transfer the list of students to another sheet and refer to it from there. All this is probably best done in a database, but I at least have some experience with Excel; I know nothing about databases. And finally, I will need to create charts displaying the number of titles from each publisher and supplier and the cost of those packages, the cost of package for each department, and the status of the orders - whether a book has been ordered, arrived, arrived but incomplete number of copies, or late.
Upon further testing - adding a more complete list of students from year 1 to 4 to the separate data sheet - I found that I need to adapt the formula: instead of counting the major in column F the way I did when I only had year 3 data, I am now counting the number of the year (1, 2, 3, 4) in column H (Year) on the new data sheet.

Excel Formula:
=IF(F8="";0;(COUNTIF(Data!$H:$H;"1")))
Excel Formula:
=IF(F11="";0;(COUNTIF(Data!$H:$H;"2")))
Excel Formula:
=IF(F16="";0;(COUNTIF(Data!$H:$H;"3")))
Excel Formula:
=IF(F23="";0;(COUNTIF(Data!$H:$H;"4")))

This works for years 1 and 2 which don't have any minors, and for common courses of years 3 and 4. I don't know how to count if the year is 3 AND the minor is Business or Economics / if the year is 4 AND the minor is Electronic and Electrical Engineering, Business or Economics. How do I incorporate columns G (minor) and H (year) into the above formulas?
 
Upvote 0
ok,
i will not be back on forum till sunday (possibly earlier) but plan is sunday
Hello, just wanted to check if you had a chance to see the updates and if you had any ideas on how to incorporate minors and years in the above formulas? It is perhaps something fairly obvious that I cannot see.
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,988
Members
449,093
Latest member
Mr Hughes

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