Calculating price per minute from total cost and minutes duration - excel

So for an interview process I was given this workbook to complete the questions on, I have no experience with arithmetic and stuff like this in excel tbh so got stumped and just did the data manipulation ones - but for future how would you actually do this?
Ignore the formula in M I thought I could get somewhere dividing the cost by minutes but that's clearly wrong.

Related

Having problems spreading expense over months with partial month calculation

I am writing a nested if statement that will calculate monthly expense based on an "Expense Frequency" option. Most of them see to be working but I have two that will not work for some reason.
The first problem is the "Fixed" option - I want this to put the whole expense rate in the first month of the expense period. For some reason it is not triggering in the first month. I feel like this might be a simple fix?
The second problem is a little more complex. It is the "Spread Amount" option. When the months are full calendar months the calculation is easy, divide total expense amount by # of months. But when I factor in partial months the calculation diverges from what I am looking for. The shorter the time duration, the larger the variance is from the total expense. When I stretch the expense over a longer period the variance shrinks. It is a pretty complex calculation (I think) and basically I want to use days out of the month for the calculation in the partial months (first and/or last) and then whole months in the middle. I have attempted this in my attached spreadsheet and I thought it might work but it isn't. Is anyone able to help me out here? I would even be satisfied with a succinct explanation of why this calculation isn't possible / doesn't make sense / cannot be done so I can explain this to my boss. I am providing a cash reward for this if it can be handled in the next three hours. Please help!! Thank you!
This is my formula
=IF($I9="Spread Amount",IF(AND($J9<=O$6,$K9>=O$5),IF(EOMONTH($J9,0)=O$6,(($M9)/(DATEDIF($J9,$K9,"m")+1)((O$6-$J9+1)/O$4)),IF(EOMONTH($K9,0)=O$6,IF(EOMONTH($K9,0)=O$6,(($M9)/(DATEDIF($J9,$K9,"m")+1)(($K9-O$5+1)/O$4))),($M9-IF(ISERROR(HLOOKUP($K9,$6:9,$XFD9,0)),HLOOKUP(EOMONTH($K9,0),$6:9,$XFD9,0),0)-IF(ISERROR(HLOOKUP($J9,$6:9,$XFD9,0)),HLOOKUP(EOMONTH($J9,0),$6:9,$XFD9,0),0))/(DATEDIF($J9,$K9,"m")))),0),IF(O$7>$K9,0,IF($I9="EOQ",IF(OR(MONTH(O$7)=3,MONTH(O$7)=6,MONTH(O$7)=9,MONTH(O$7)=12),$M9,0),IF($I9="Spread Evenly",IF(AND($J9<=O$6,$K9>=O$5),IF(EOMONTH($J9,0)=O$6,$M9*((O$6-$J9+1)/O$4),IF(EOMONTH($K9,0)=O$6,$M9*(($K9-O$5+1)/O$4),$M9)),IF($I9="Fixed",IF(AND($J9>=O$5,$J9<=O$6),$M9,0),IF($I9="Repeat Annually",IF(MONTH($J9)=MONTH(O$6),$M9,0),0))),IF($I9="Odd Month",IF(ISODD(MONTH(O$6)),$M9,0),IF($I9="Daily",IF(AND($J9<=O$6,$K9>=O$5),IF(EOMONTH($J9,0)=O$6,($M9/($K9-$J9+1))(O$6-$J9+1),IF(EOMONTH($K9,0)=O$6,($M9/($K9-$J9+1))($K9-O$5+1),($M9/($K9-$J9+1))*O$4)),0))))))*1)
This is what the spreadsheet looks like

Excel subtract X days from date and then find last specific workday date

here's my problem:
We have an Excel sheet at work in order to manage various tasks all set on individually specified timelines - we're talking hundreds of tasks per month with dates that are currently all being maintained manually.
Let's say we have Task A and that task has a Due Date. That Task is split into several subtasks, all with their individual due dates. Date 1 would then always be Due Date - 10 days, Date 2 would be Due Date - 20 days, Date 3 would be Due Date - 17 days and so on. This then creates a neat timeline of when everything needs to be done.
That in itself would be easy enough, problem is that all of these subtasks have to be done on a specific workday as well. Meaning that subtask 1 would not only have to be done Due Date - 10 days, but it would also have to fall on a Monday - if for whatever reason Due Date - 10 would happen to fall on like a Wednesday, it would have to subtract another 2 days. And then the real problem is that Date 2 and 3 each have to fall on different workdays and Task B has an entirely different schedule again.
Now, the first thing that came to my mind was attempting to just nest a couple IFs - and I've even managed to come up with a working formula for that. Problem here is that it's so stupidly long and (thanks Excel) utterly unreadable - if for some reason someone else had to change something about it or troubleshoot the entire file 1-2 years from now, they'd probably have to spend at least an hour reconstruct how the hell any of it actually worked. Which doesn't sound particularly appealing to us.
Here's a screenshot to help illustrating the situation:
And here's a draft of the current formula that I'm really not happy with, despite it somewhat doing the job:
=IF(AND(WEEKDAY(K2-VLOOKUP(B2,Table1,3,FALSE),11)>5,VLOOKUP(B2,Table1,5,FALSE)=0),(K2-VLOOKUP(B2,Table1,3,FALSE))-(WEEKDAY(K2-VLOOKUP(B2,Table1,3,FALSE),11)-5), IF(VLOOKUP(B2,Table1,5,FALSE)=0,K2-VLOOKUP(B2,Table1,3,FALSE), IF(WEEKDAY((K2-VLOOKUP(B2,Table1,3,FALSE)),11)=0,K2-VLOOKUP(B2,Table1,3,FALSE), (VLOOKUP(B2,Table1,5,FALSE)-WEEKDAY(K2-VLOOKUP(B2,Table1,3,FALSE),11))+K2-VLOOKUP(B2,Table1,3,FALSE))))
My question is now: Does anyone have an idea how to solve this in a less confusing and unclear manner? I was trying to get something done using =CHOOSE() but ultimately ended up with the same problem of eventually having to resort to 7 IFs and dozens of LOOKUPs, making the final formula just as long. I wouldn't be disinclined towards some kind of helper table that asigns the last 7 days and their workdays to every single day of the year... but I don't think tossing another 20,000 calculated cells into a file that already has tens of thousands other calculated cells would really be a serviceable alternative... or make the situation any less obscure at all tbh.
So, anyone any idea how to go about this? Or is there really no realistic alternative than to use a bunch of IFs?
Edit: Forgot to mention that 1 special case:
There's also the situation when a date doesn't have to fall on a specific workday - in which case it's simply due date - X days. The problem here is that in those cases the dates could fall on a weekend, so the formula would have to move these dates to the previous Friday as well.
Assume you have some date and you want to "back up" ten days and then to the preceding Monday, unless the resultant date is a Monday. The general formula would be something like:
=A2-10+1-WEEKDAY(A2-10-DOW)
Where DOW translates into
Sunday=0
Monday=1
Tuesday=2
...
You should be able to modify your formulas to use this algorithm for day of the week.
If the two tables are named thisTable and keyTable, the following 365 formula is one way of implementing:
If your tables are as below, you can enter the formula in B2 and fill down and across. The references should self-adjust and return the proper dates.
Note that in keyTable, I enter the day of the week DOW as defined above, and not the textual date.
=LET(dys,VLOOKUP(thisTable[#[Task]:[Task]],KeyTable,COLUMNS($A:A)*2,FALSE),
dow,VLOOKUP(thisTable[#[Task]:{Task]],KeyTable,COLUMNS($A:A)*2+1,FALSE),
due,thisTable[#[DueDate]:[DueDate]],
IF(dow="flexible",WORKDAY(due-dys+1,-1),due-dys+1-WEEKDAY(due-dys-dow)))
If you want to have the result be the closest workday, instead of the preceding workday, then you need to add two clauses to the LET function
Calculate the subsequent workday date
Then use an IF to return the closest one to the original target
eg:
=LET(dys,VLOOKUP(thisTable[#[Task]:[Task]],KeyTable,COLUMNS($A:A)*2,FALSE),
dow,VLOOKUP(thisTable[#[Task]:[Task]],KeyTable,COLUMNS($A:A)*2+1,FALSE),
due,thisTable[#[DueDate]:[DueDate]],
dayPrev,IF(dow="flexible",WORKDAY(due-dys+1,-1),due-dys+1-WEEKDAY(due-dys-dow)),
daySubseq,IF(dow="flexible",WORKDAY(due-dys+1,-1),due-dys+7-WEEKDAY(due-dys-1-dow)),
IF((daySubseq-due+dys)>3,dayPrev,daySubseq))

Excell 2016 - Is this average time correct?

So I am trying to find my average time in Excel and I have been using the average function but even though I do not know what the exact value should be I know that what was being returned was way off. So I googled Excel time format and followed the instructions and changed my time from MM:SS format to H:MM:SS format; because the article said that way I am guaranteed to get correct averages when I use Excel's native average function.
However, I am running Excels average function on mixed values like the below:
1:20:30
0:04:00
0:00:30
0:00:05
--------
Average: 0:21:16
Can someone just please share their expertise with me and verify that the above average calculation is correct that I obtained by just easily using Excel's native average function.
I just want to be sure before I change everything on my spreadsheet.
Working with times and their various formats/representations can be tricky in Excel - sometimes I convert to serial and then multiply by 24 to ascertain the number of hours in the day, other times not. In your case, this appears to be straight forward and can easily be verified.
Here/screenshot refer:
Mathematically: you can determine the number of hours, minutes, seconds directly from what you have using respective equations as follows:
=hour(E4)
=minute(E4)
=second(E4)
Determining the average is then a trivial exercise by summing and dividing by the count (4), which reconciles (as can be seen).
Let's apply logic too: average of 21 mins looks about right - consider equivalent scenario of average running time for 4 athletes, where one of them takes 80 mins and the others take under 5 each - average time will be around 20 mins (~80/4).

Excel Time addition

First time poster and new joiner.
So I’m having a little difficulty is attempting to take a “lapsed time” with a format of 0:00:00 from a stated time (in this case I’m using a time stamp)
What I would like to achieve is the following.
Let’s say I attain some data from an external source that shows me the lapsed time someone hasn’t been logged In from their expected time. Now unfortunately the time due isn’t readily available so I want to put in A1 (CTRL + shift and ; for my time stamp) and then in B1 I want to minus the lapsed time. And in C1 a subtraction formula that will give me (there or about a the time that should be due to log in)
The issue I’m facing is this, I’ve tried a simple minus, a TIME function and both give a value error
I’m unsure whether firstly the fact that my time stamp being only hours and minutes is an issue but also when I attempt to remove the seconds from the lapsed time it won’t easily format out without manual input from me.
I feel like I’m being stupid here but cannot seem to get say;
14:55 to minus 0:25:00 to give me 14:00 !!
For clarity I have tried to format the time to include seconds but still not use...
Is there an easy way to conver the lapsed time to minutes for easier use of TIME ?
14:55 to minus 0:25:00 to give me 14:00
I think you wanted to say "... to give me 14:30".
Well, you can do subtraction of time values:

How to reference the previous month's high or low in a data set and compare it with the current value

I have an Excel spreadsheet of daily Open/High/Low/Close data for an stock index (link below) and wish to go through the data day by day to create a marker for each day. I would like this to be +1 if the high of the day is above the high of the previous month, -1 if the low of the day is below the previous month's low and 0 if neither of these conditions are satisfied. A previous answer on this forum showed me how to extract the monthly high and low for each month (also in the spreadsheet). It seems quite straightforward on the face of it but I can't seem to get anywhere. I've been trying to use nested "if" statements to do this. I have actually asked this question before but I had no response. Any help would be much appreciated.
Many Thanks, Paul
Link to image
https://imgur.com/gallery/rJen7xw

Resources