Recovery Time Calculation Supply vs Demand - analytics

I have a scenario where I am comparing the output of an item to its required output which is done weekly. I calculate the percentage of actual output against required output which can be seen in the Requirement Met % row below.
Where I'm struggling is with the recovery time metric. I'm trying to calculate the recovery time where Actual Output is short of the required output, and how long it takes to back fill a shortage.
So for week 1 in the image above, only 90% of the required output was fulfilled and therefore had a shortage of 10%. I'd then look at week 2 to fill week 1's shortage, however week 2 is also short 10% from its required output. So I'd then need to look at week 3 to fulfill week 1's shortage. This is possible as week 3 has more output than its required output (113%) and enough to fulfill week 1's shortage. This means it took an extra 2 weeks for week 1's requirement output to be met. The same would apply to week 2, it would look at the next week until its required output shortage can be met.
After week 3's required output and week 1's shortage are deducted from week 3's actual output, that leaves 3% which is not enough to fulfill week 2's required output. So I'd look at week 4 to see if it has enough leftover output to fulfill week 2's shortage...which it does. And so on and so on.
This would show the recovery time for each week.
I am working in alteryx but have not attempted to do this yet as I haven't worked out how to calculate this figure. If not alteryx I could do it in power BI but it's really how to calculate this metric that I'm after.
Thanks,
Tom

Related

Getting an average from a nested calculation with averageifs in excel

i am trying to pull performance data togther from a csv. We have a design team with a list of tasks which arrive on their list, sit there until dealt with, and then get completed. For any given day i want to calculate:
1/ The number of tasks on the list (so i'm running countifs, with citeria being 1: the design team, 2: the task had arrived on the list by the given day, and 3: had not been completed by the given day. This works ok.
2/ I also want to know what the average amonth of days those tasks had been on the list on that given day. IN the data set i have the day they arrive, and the day they got completed, and i know the given day i want to calculate for. So i think i ned to nest a formula to calculate (given date - arrival date) into an averageifs formula with the same conditions as the task count.
I have set this up in a sheet using a helper column to give me the days elapsed, but in practice, i want to run this for a number of given days so cannot add a helper column for each query.
So i have =AVERAGEIFS($G:$G,B:B,"Design",$C:$C, "<"&I$1, $E:$E, ">="&I$1)
but where $G:$G is a calculation of the days elapsed =IF(C2<>"",SUM(I$1-C2),"")
enter image description here

what are the best possible ways to find the next earliest possible time from given HH:MM 24 hour format

similar types of question are there on stackoverflow
but from the 24 hour format HH:MM ,what are the best ways to find the next earliest time
if 12:00 is given then the ans is 21:00
I think I’d generate all possible times from the digits of the original time (here 12:00), sort them and see which comes after the original one.
With more detail: Generate all unique permutations of the digits. If you don’t know how to generate permutations, search the web, it’s covered in many places. It’s probably easiest to generate all permutations and then filter out duplicates. Validate each permutation and discard those that are not valid times if any. For example there is no such time as 12:63 or 31:14. If using Java, use LocalTime.parse for validation. Sort the times using their natural order. Find the original in the sorted list. Return the subsequent list element.
Edit: The following description does not give you the correct next time in all cases.
It’s possible to go more directly for just finding the next time without finding all times, but it’s a bit complicated. First thing to do is to search the time string from the right for where there’s a smaller digit before a greater one (in your example you will find that 1 is before 2). Among the digits visited so far, choose the next digit higher than the smaller digit found. In your example, the next digit higher than 1 is 2. Put this digit where the lower digit was and reverse the order of the remaining digits. The reverse of 100 is 001, so your result is 20:01,, which I believe is the correct answer. For a different example, 01:20, again 1 is before 2, so put 2 there, reverse 10 into 01 to get 02:01. If you get an invalid time, repeat the process. If there is no smaller digit before a greater one, you have exhausted the possible times of the day. If you want to start over, reverse the entire string: from 21:00 you will get 00:12.

Excel function array formula based on sumif to find minimum count

I have some data where I want to find the minimum number of days it takes to reach a total sum based on some criteria.
Essentially the data is like this:
Date Season Recieval
1/01/2006 2006 500
2/01/2006 2006 100
3/01/2006 2006 150
…
10/12/2009 2009 300
etc
Want I want to do is find a formula that finds the minimum number of days it takes to reach a receivals total for the season.
The formula below is what I have tried so far with no avail.
=MIN(COUNT(IF(SUMIFS(C:C,B:B,"2006")>2000,DATA!A:A)))
It doesn't matter what point it starts from, but it must take the minimum number of days to reach the 2000.
Output should be a number eg 39 (39 days consecutive to sum up to receivals of 2000).
Essentially what I want to generate is the minimum number of consecutive days required to reach the total of 2000, regardless of the starting point.
Cheers!
If your Dates are in the range A2:A25 and Recieval in C2:C25, then try this...
=INDEX(A2:A25,MATCH(TRUE,INDEX(SUBTOTAL(9,(OFFSET(C$2:C25,,,ROW(INDIRECT("1:25")),1)))>=2000,),0))-A2
The formula will get you the no. of days to reach total 2000 receival in column C.
Or if you just need to count the consecutive dates, please try..
=MATCH(TRUE,INDEX(SUBTOTAL(9,(OFFSET(C$2:C25,,,ROW(INDIRECT("1:25")),1)))>=2000,),0)
Remember both the formulas are Array Formulas which require a special key stroke Ctrl+Shift+Enter instead of Enter alone.

Rolling Arrays as a possible solution to a rolling window in SAS

I am trying to calculate the dosage of a particular drug for a population to see if any member in this population is over a certain threshold for any 90 consecutive days. So to do this I am thinking that I am going to need to make a arraty that looks at the strengh of this drug over 90 days from an index and if they are all '1' then they get a 'pass', and somehow put this into a do loop to look at all of the potential 90 day windows for a year i=1...i=275 to see if a member at any point during the year has met the criteria. Thoughts?

Calculating dates ( with limited tools)

I'm trying go calculate difference between two dates, for homework.
Only problem is we can't use anything outside of for while if loops.. which is driving me crazy. I tried writing the sudocode for it and it seems simple enough but when I start sitting down and coding I get lost when the months start coming in.(excluding leap years)
Say the start dates is July 3 2015 going to March 5 2016.
I was originaly going to add days until the current month is finish and pretty much calculate everything from days. But I get kinda lost when I start including different days for each month.
An idea to work out how far you can go in that month might be
for(day=1;day<=days_in_month(month);day++){
counter++;
}
Then have a days_in_month function, that returns, using a few if statements. If you have a bit of google I remember seeing a few good statements to efficiently work this out - if you need to include leap years you'll obviously need to pass the year to the days_in_month function.
Oviously you'll need the above loop nested some other ones.
Hope this helps, good luck.
Step 1: Write a function to convert a date into a "day number since epoc", which takes into account things like leap years, etc. The epoc could probably be "1/1/1970". It'd be easy to just use lookup tables - one for "days in previous years" that includes a leap year flag and one for "days in previous months" for non-leap years (where if the leap year flag from the previous table is set and the month is after February, you add a day). Then you'd add "days in previous years", "days in previous months" and the day of the month to get "day number since epoc".
Step 2: Convert both dates into "day number since epoc" integers and subtract.
Note: The lecturer might expect you to use calculations rather than using lookup tables. In this case, use lookup tables to get it working, then replace the lookup tables one at a time.

Resources