How do I set a value limit to a specific cell in Excel and add exceding entries to another cell? - excel

Over the past couple of days, I've had a hard time figuring out an issue that is supposed to be easy but I just can't wrap my head around.
To add some context, here's what I'm trying to do: I'm working on a class attendance sheet for teachers to keep track of students' attendance. In order to submit an entry, teachers will have to fill in 4 different cells: Date, Time, Lesson Content and Status (whether the class took place or the student didn't show up). I've added a dropdown to the Status cell so that the teacher chooses between predetermined codes (more on that soon).
I've also included a separate sheet where the school will register eventual replacement classes set up in alternative schedules, and it works in a similar fashion to the overall attendance sheet.
The third and last sheet in this workbook (where I'm having some issues) is an Hour Bank that is calculated based on the amount of cancellations versus the replacement classes the student scheduled and attended.
Here's where the issue kicks in. As I mentioned, I would like to create an Hour Bank System in order to store the classes that are "replaceable". This would be a relatively simple task, the only issue is that I also need to establish a cap (which is 8) so that the Hour Bank will not add beyond this specific number. The Hour Bank works fine, but the number doesn't go down immediately if the student exceeds the cap. If the student has, for instance, 2 classes over the cap, the Hour Bank Balance only goes down to 7 if I enter two replacement classes. However, I would like this particular cell to cap at 8 and go down as soon as a replacement class is registered, regardless of how many hours the student exceeds this cap.
Here are the elements contained in the 3rd sheet:
-Total Classes Given (D8): This part works fine. It's just a SUMIF with the specific code that means "Class ok". Code below:
=SUMIF(FREQ!F9:F106;"AR";FREQ!G9:G106)
-Total Client Cancellations (D11): This part also works fine. It's another SUMIF with the specific code meaning that the student didn't show up to class and didn't notify the school. These classes won't be accounted for in the hour bank. Code below:
=SUMIF(FREQ!F9:F106;"AC (Aluno)";FREQ!G9:G106)
-Total Replaceable Classes (D14): This part works fine. It's a combination of two SUMIFs with the codes that mean "Ok, student didn't come but we'll let them schedule a replacement class". Code below:
=SUMIF(FREQ!F9:F106;"PP";FREQ!G12:G109) + SUMIF(FREQ!F9:F106;"AC (Miles)";FREQ!G12:G109)
-Attendance Rate (D17): This part also works fine. It just shows the percentage of the classes that the student has attended up until the present moment. Code below:
=IF(D8>0; D8/FREQ!G107; "0,00%")
-Pending Replacement Classes (G8): This part works fine. It is a simple subtraction that calculates how many classes are pending (not considering the cap). This number goes down as I enter replacement classes in the second sheet of the workbook, and goes up as the teacher registers replaceable cancellations in the first sheet. Code below:
=D14-G11
-Given Replacement Classes (G11): This part works fine. It is a SUMIF that keeps track of how many replacement classes were given in total. Code:
=SUMIF(REPO!F9:F106;"AR";REPO!G9:G106)
-Exceding Hours (G14): This cell is broken. I'd like it to compute the amount of hours that the student has cancelled over the established cap. It does work when it comes to only computing the hours over the cap, but the issue is that it decreases as I enter replacement classes in the 2nd sheet of the workbook instead of subtracting them from the Hour Bank Balance which I will explain below.
=IF(G17=8; G8-8; 0)
-Hour Bank Balance (G17): This cell is broken, and it's the most important part of the entire workbook. I would like it to compute the replaceable classes up until the cap (which is 8) and make it go down immediately as a replacement class is registered. However, if the student has Exceding Hours (G14), the replacement classes are substracted from G14 instead of G17, which is what I wanted. The Hour Bank Balance (G17) will only go down if the Exceding Hours (G14) equals zero. Here's the code:
=IF((D14-G11)>8; 8; D14-G11)
I hope I was clear enough and I'm willing to provide screenshots if need be. I'm sure there's a problem with my maths or something, but I've been unable to spot it.
Please help a brother out!
Thanks in advance

I think that this formula might be what you’re looking for:
=IF((D14 - G11) > 8, 8, IF(D14 > 8, 8, D14) - G11)
The first part of this formula would give 8 as a value if D14 - G11 is greater than 8; the second part of this formula yields D14 - G11 except for in cases where D14 is greater than 8, then it gives 8 - G11. Hopefully this is what you were looking for.

Related

Excel - Automatic allocation of preferences

Edit: Example file available here.
I'm not a super experienced Excel user, but I'm trying to automate using IF/AND/INDEX/MATCH to assign yes/no to preferences which competitively listed people have chosen from a list of about 300 choices. Each person has listed 4 preferences, there's over 1000 people in the process, and each person gets one preference out of four. A simplified hypothetical version of it is a situation where I want automate the allocation of employee shifts at a restaurant, with the employee data listed with the best workers at the top and the worst ones at the bottom.
Traditionally the Shift Allocation sheet has been done manually, which is fine when you have seven days of the week and maybe 30 employees. But if I have 300 days of the week and 1000 employees, I don't want to manually allocate each one to their preferences. Or if I do have a manual input, I want it to automate enough shift allocation beforehand so it doesn't take up as much time.
Ideally the automated formula to assign the yes/no indicator for the shift in the Shift Allocation would look at the first preference (day of the week) the person has listed in the Employee Data sheet, check the Shifts Available sheet to find the day of the week and then look at the number of shifts available in column K, if column K is more than 0, assign YES to that employee's preference on the Shift Allocation sheet, then move on to the next employee.
The employees are listed by who gets first pick, so in theory some people at the bottom may not get the shifts they preferenced, or there may need to be other manual changes made after the automatic allocation process for other reasons.
I tried VLOOKUP but the lookup logic wasn't broad enough, so I need something like an INDEX/MATCH parameter to find the shift places available in column K of the Shifts Available sheet after finding the day of the week in Column A.
This is about as far as I got with the code
=IF(AND(INDEX('Shifts Available'!$A$2:$K$8, MATCH('Employee Data'!$A$2,0)), 'Shifts Available'![K-column cell corresponding to the day of the week, unsure how to do this? Keep it in the INDEX?]) >=0)"Yes", "No")
Any help is appreciated.

Calculate minutes in specific period

I have a spreadsheet which has employee working times, listed as Sat-In and Sat-Out for a specific date. The employee shift spans several ours and each "In-Out" period is recorded as a separate line which means the time between the Sat-Out and the next Sat-In means the employee is on a break. I also calculate the time, in minutes of each "sitting" period.
What I can't seem to figure out is how to add a formula which takes the data and further refines it in this manner:
1. I have a core period of 1030-1530, as an example, which is the busy time and requires the maximum employee coverage. The shifts of employees generally spans this core, but in some cases their shift may start or end in the core.
2. I want to calculate how many minutes the employee worked within the core only. I can obviously do this manually using the data, but a formula would be preferred, if possible.
3. As an example, if a person sat-in at 1445 and sat-out at 1545, the core time calculation would be 45 minutes (1445-1530).
I've attached a snapshot of the data to help my explanation.
FYI - the information is pulled from a database as JSON data and converted to excel. I'm not very familiar with JavaScript, but if someone knows a way to do it programatically, I'm willing to give it a try and learn.
Thanks!
![excel]: https://photos.app.goo.gl/dRSTE72CXNa18RzP8
In below example I've used: =MAX(0,MIN($O$2,H2)-MAX($O$1,G2)), and formatted like [mm].
In Excel, units are days, so if you want to calculate the amount of minutes between two timestamps, you need to subtract both and multiply the differencee by 24*60 (being the amount of minutes in one day).
E.g. You start working at 09:07 (cell B2), and finish at 18:07 (cell B3), having a 45-minutes break. Then the time you worked in minutes, is:
=(B3-B2)*24*60-45
Make sure the cell formatting is correct (general), you'll get : 495.

Index Match Match across multiple columns

I have an Index Match Match question that I have not been able to find the answer for in researching. Although the solution may actually might be different than an Index Match Match formula - I'm open to try something more efficient than my current workaround.
I have one worksheet with data from my company on it. We sell a Product (let's call it Coke Zero) and we track the weeks that we put a promotion on and how much profit we make by selling it to the retailer. For example a promotion for Coke Zero starts the first week of Jan and ends 3 weeks later and we make a gross profit of $100 each week the promotion runs. I then have an external database with sales data formatted on a weekly basis to tell me how many units of Coke Zero I sold in each week. My internal data has thousands of lines like this with dozens of products, however the promotions are consolidated on one single row regardless of if it runs for more than one week, making matching up to the external database difficult. I need to create a lookup for what our Gross Profit was for each week of the promotion.
I have attached an example image of the workbook + two data sheets of what I've tried to do, summarised below.
On the Internal Data Sheet I've created additional columns to the right with all of the weeks listed that the promotion is on for, and concatenated them with the Product Code to be able to match week by week to the data in the External data sheet. Then my lookup basically checks every column one after another until it finds one where the concatenate of Week_Product Code concatenate matches.
My current solution technically works but my final formula is really slow and cumbersome given the data can be anywhere from 10K-200K lines when looking at multiple retailers. I was hoping to find a more efficient formula to complete the lookup.
Current solution on the External Data Sheet Column E:
=IF(ISNUMBER(MATCH(D2,'Internal Data'!$E:$E,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$E:$E,0)),
IF(ISNUMBER(MATCH(D2,'Internal Data'!$F:$F,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$F:$F,0)),
IF(ISNUMBER(MATCH(D2,'Internal Data'!$G:$G,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$G:$G,0)),
"0")))
I got SUMPRODUCT to work using this formula in J2:
=SUMPRODUCT(--($B$2:$D$3=H2)*--($E$2:$E$3=I2)*$F$2:$F$3)
And, you don't need those concatenated lookup columns:
Well, that was fun.

Dynamic Sales Summary Depending on Month (can't use MAXIF/MINIF)

I have a student license of Office Pro 2016, but somehow it doesn't have the IFS, MINIF/MINIFS, MAXIF/MAXIFS functions that would make my life so much easier. I tried to illustrate what I'm doing in the image below:
Example
My actual data is much more complicated and long, but the idea is that I will periodically manually update data within the DATATABLE, and I want the SUMMARYTABLE to reflect the total pending sales by month. There are never more than two months pending at a time, and if only sales from one particular month are pending, I don't want the second row to appear.
I've already found a way to display the month in this case using regular MAX and MIN functions, but now I'm stumped as to how to display the sum total of sales within those months. Specifically, I don't know how to make a reference to a particular month in my criteria.
I've tried this formula:
=SUMIFS(DATATABLE[SALES],DATATABLE[SHOP]="A",DATATABLE[STATUS]="PENDING",MONTH(DATATABLE[DATE]),SHOPATOTALS[MONTH])
If this worked it would have been perfect, but the month portion isn't recognized as a proper range.

How Do I Nest IF Functions in Order to Calculate Daily Revenue?

I am working on a data set and I need to calculate the daily revenue of fake AirBnb listings using nested IF statements. This is for a bootcamp I am attending, and I am stuck.
My instructions are as follows:
Estimate revenue per listing
Assume each booking always has 2 guests, unless the listing accommodates only one;
The booking is always for the minimum number of days allowed;
Only half of the bookings generate a review;
The extra person charge is per night (column name ‘extra_people’)
○ Format: have a column that calculates daily revenue (account for number of guests accommodated, number of guests included in the price, extra charge for additional people - using nested IF statements); another column would then calculates revenue per booking; finally, multiply that by the number of total stays the listings has had.
Using the data in my dataset, I am attempting to fill out column AA. So far this is what I have for my formula,
However, I get an error. I know the first part of this formula would work for the scenario in row 4. However, I need to make sure that the formula takes into account scenarios where the "guests included" is less than the "accommodates", because I must assume that each booking always has two guests except for when the listing only accommodates one person.
How should this formula be written? Can I not create equations within nested if formulas if it includes adding, subtracting, dividing, or multiplying columns together?
To clarify the previous response a bit more, the structuring of IFstatements is important. Keep in mind the structure of the function: =IF(logical test, value if true, value if false). So, the second IF function (the first nested) needs to be placed where the first "value if false" comes in - each additional IF needs to be within the previous IF function. Using your example, the corrected form would be =IF(W4=Q4,V4,IF(W4<Q4,Q4*V4...)). I'm not sure what the "+X4" is supposed to be adding to, but this hopefully makes the structure clearer for you to work with. Good luck!

Resources