Redistribution of remaining percentages in excel - excel

I'm having a hard time getting some excel formulas correct. The goal is to redistribute any "lost" Change in Stake (negative values) as positive additions to other rows (the calculation is based mainly on Inactive Hours and each stackholder's original Stake
In this example, the "period" is 5 days and Row 1 controls 28.15% of the stake. so
STAKE PER DAY = 28.15% / 5
I calculate what percentage is lost during 25 hours of inactivity:
(25/24 hours) x 5.63% = ~5.86%
In this case Row 1 loses 5.86% percent for their inactivity, while all other members with lesser inactive hours than 25, get that 5.86% distributed amongst them based on their original stake. So Row 2 gets 21.93% of 5.86%, and so forth.
Stak
This formula was making my head spin last night:
=IF(B25<>"",IF(D25="YES",IF([INACTIVE HOURS] > 0, -[#[INACTIVE HOURS]]/24*[#[STAKE PER DAY]], [#[ STAKE]]/($K$40+ SUMPRODUCT([[ STAKE]],[#[INACTIVE HOURS]]/24*[STAKE PER DAY], 0))),0),"")
Stayed up real late trying to crack it but the closest I got to getting the totals in Change In Stake to sum to 0.00% (I get 0.16%) and Final Adjusted Stake to sum to 100% (I get 99.84%).
There's also more to this problem. Consider there can also be multiple rows with different values for inactive hours.
For example, the row with 28.15% had 25 inactive hours, Row with 15.71% had 15 inactive hours and Row with 12.44% had 10 inactive hours.
In that case, only 10 of those hours will be fully distributed away from all 3 of these parties, and redistributed to the parties who had 0 inactive hours. However, the stakeholder with 12.44% was only inactive for 10 hours, as opposed to the stakeholder 28.15% who was inactive for 25 hours.
Therefore, stakeholder 12.44% will lose and full redistribute 10 hours worth but will also gain some back from the stakeholders with 15 and 25 hours of inactivity, during which stakeholder 12.44% was active. Likewise, the 15 hours stackholder is entitled to a proportionate share from the stackholder who was inactive for 10 hours more than they were.
Can excel formulas handle this type of calculation? What would it look like?

I think your partial solution is complicating the underlying problem so I would propose a different method. Reading between the lines the issue is to reduce/increase each stakeholders share by the inactive/active hours.
Calculate an equivalent number of hours from the total hours (share * 5 days * 24 hrs), subtract off the inactive hours, re-base the share on the new lower total. See the image below.

Related

Excel formula or VBA Identifying gaps in overlapping dates and times

I am attempting to find any gaps calculated in minutes between a start and stop date/time range. Essentially time when there are no appointments in the schedule, this is a 24hr service and I am looking for "dead" time when there isn't a customer in the office.
Currently I was attempting to use the =SUMPRODUCT((A2<B$2:B$19)*(B2>A$2:A$19))>1 to find overlaps and the issue I am running into is if there are any overlap in start or stop it disqualifies and does not truly identify the space between appointments just if that appointment is double booked at all.
Here is a new version of the Gap and Island solution to this problem, using Excel 365 functionality:
=LET(start,A2:A19,
end,B2:B19,
row,SEQUENCE(ROWS(start)),
maxSoFar,SCAN(0,row,LAMBDA(a,c,IF(c=1,INDEX(start,1),IF(INDEX(end,c-1)>a,INDEX(end,c-1),a)))),
SUM(IF(start>maxSoFar,start-maxSoFar,0)))
The algorithm is very simple:
- Sort data by start time if necessary, then for each pair of times:
- Record the latest finish time so far (maxSoFar) (not including the present appointment)
- If the start time (start) is greater than maxSoFar, add start-maxSoFar to the total.
The first time interval is a special case - initialise maxSoFar to the first start time.
It can be seen that there are only two gaps in the appointments, from 4:15 to 7:31 (3 hours 16 minutes) and from 11:48 to 14:17 (3 hours 29 minutes) totalling 5 hours 45 minutes.
Why didn't I just use Max to make the code shorter? I don't know:
=LET(start,A2:A19,
end,B2:B19,
row,SEQUENCE(ROWS(start)),
maxSoFar,SCAN(0,row,LAMBDA(a,c,IF(c=1,INDEX(start,1),MAX(INDEX(end,c-1),a)))),
SUM(IF(start>maxSoFar,start-maxSoFar,0)))
To find the gaps between appointments in a schedule, you can try using the following formula:
=SUM(B2:B19)-SUMPRODUCT((A2<B$2:B$19)*(B2>A$2:A$19))
You can then convert the duration to minutes by multiplying the result by 1440 (the number of minutes in a day).
=1440*(SUM(B2:B19)-SUMPRODUCT((A2<B$2:B$19)*(B2>A$2:A$19)))

How to count appearences along a timeline with criteria

I have a table with 3 columns: expense, client_id, date.
The date has record of clients expense for half a year for each day.
Some clients spend many each day, but some not.
The expendure ranging from zero to few hundreds.
I want to group/count active client, which spend over 50 dollars each day, and calculate how much clients was active between 0-30 days, 30-60 days, 60-90 days, 90-120 days, 120-150 days, 150+.
I mean if client spend at least 50 dollars each day along 40 days, i add him to 30-60 days column.
client id appears only once each day.
expense
client_id
date
20
1
01/01/2000
60
2
01/01/2020
70
3
01/02/2020
the result should be like that
0-30 days
30-60 days
60-90 days
90-120 days
9
3
12
20
the values are count of active clients
Thank you a lot
There might be better solutions with less helper columns, but this is what I can offer at the moment.
Preparation
I generated some random data in columns A to C for 10 clients, one month and an expense limit of 100. You will have to adjust the expense threshold and the day ranges to your needs.
Helper columns and formulas
criteria_met checks whether the expense is higher or equal the given threshold (here 10). Formula in D2 is =IF(A2>=10,TRUE,FALSE).
is_consecutive checks whether the client had an entry on the previous day. Formula in E2 is =IF(COUNTIFS(B$1:B1,B2,C$1:C1,C2-1)>0,TRUE,FALSE).
consecutive_group assigns a number for each group of consecutive days, on which the client had an expenditure above or equal the threshold. Formula in F2 is =IF(AND(D2=TRUE,E2=TRUE),MAXIFS(F$1:F1,B$1:B1,B2),MAXIFS(F$1:F1,B$1:B1,B2)+1). Whenever the combination of criteria_met and is_consecutive is FALSE, the group number is increased by one.
days_per_group counts the number of days per client_id and consecutive_group. Formula in G2 is =COUNTIFS(B$1:B2,B2,F$1:F2,F2).
max_per_group makes sure that only the max number of consecutive days is considered per consecutive group. Formula in H2 is =IF(G2=MAXIFS(G:G,B:B,B2,F:F,F2),G2,0).
Result table
labels creates the headline. Formula in J3 is =J2&"-"&K2-1&" days"
values counts how often a number between the given thresholds occured. Formula in J4 is =COUNTIFS($H:$H,">="&I$2,$H:$H,"<"&J$2).
Requirements
Each client can only have one entry per day
The source list (A:C) has to be sorted by date
Please let me know, if you need more information.
how to count values in K4 ?
=COUNTIFS($H:$H,">="&J$2,$H:$H,"<"&K$2)

Excel - What is the best way to analyse the following data?

I'm looking for the best way to analyse the following data.
This is the amount in hours an employee has taken in a year and what remains. The data bars are a percent of hours taken from what they're allotted, shown in column K. Col I is how many hours they have left, and col J shows the cumulative holiday they've taken throughout the year.
I need the relevant info shown on one row where each row will be an employee's holiday history. Different employees have different hours and I need a way that shows who is in most need of taking holiday when that filtering from largest to smallest etc.
Where I find this tricky is if an employee had 10 hours allotted, and has taken 2 hours, that's 20%, which is the same if someone had 100 hours and has only taken 20 hours. But it's clearly more important that the second employee uses up some of their leave. I'm struggling with the best way to represent this.

How do I transform my maths totals into a time duration?

At work we use a spreadsheet to calculate how long delivery will take to complete, depending on people working on delivery and the amount we receive.
It frustrates me that we end up with a value of say 3.75 hours.
The .75 actually represents .75 of an hour and not 1hr 25minutes like you may first have thought.
I'm wanting the spreadsheet to say the time 3:45 minutes, not 3:75 minutes.
Is this even possible?
It gets more tricky though as we have to assume we will process 200 pieces per hour so the formula is slightly backwards. For example:
Fill Grade: 55 (pieces in each crate)
Crates: 10
Total Pieces 550 (fill grade * crates)
Process Time: (total pieces /200)
Clear rail time (puting stock out on shop floor, total pieces/400)
Total time = ???
I'm wanting to do this because of the stupidity of our current system. We print the spreadsheet then use a calculator to add up all the values. We are effectively just using the grid of the Excel spreadsheet to rota in people's time.
***** Updated information *****
Click here to see a screenshot of the current situation.
You can see that 'Pro Time' and 'C/R Time' is now correct but the total is wrong. I'm also having to total 'Pro Time' and 'C/R Time' by adding up in the boxes just to the right-hand side as you can see.
Advice?
The way to do this is whatever your formula in Total time is - let's assume it is (Process Time + Clear Rail time), then enter the formula there as (Process Time + Clear Rail time)/24.
IMP: That divide by 24 should be included, which is an addition to whatever formula you had there before.
Then select your Total Time column>> Format Cells (also Ctrl+1)>>Select Time (HH:MM:SS type)
This will show your value in hours, mins and seconds.
PS: (based on comments) IMP - if you use divide by 24 on on Process Time and Clear Rail Time, then you should not use it on Total Time, as the conversion is already done. In such a case, Total time is just addition of the previous two.
Illustrative Image
Take the fractional(modulus) part e.g. the .75. divide by 100 and then multiply by 60. (or just simply multiply by 0.6.
e.g. (where C4 contains the hours and centi hours (if that's the correct term).
=MOD(C4,1) * 0.6
Assuming the above is in D4 ..
Then in E4 =INT(C4)+D4
However datetime might be a better route. Note sue of the functions but then you could add. In short datetime, if I recall correctly is a number eg something like Date+1 adds a day.

Formula that will calculate total hours in overlapping date array

I've been trying to solve an issue for a while now and I'm just not getting the results I need. I have a spreadsheet that captures labor hours at a mechanic shop and I want to find out how many hours of labor per mechanic. The system uses open work-orders to calculate labor hours, however it allows for multiple work-orders to be open for one mechanic and the date/time of those work-orders often overlaps.
For instance, Mechanic A opens three work-orders on the same day:
WO #1 opened on 5/1/2015 # 12:00 noon, closed at 4 pm.
WO #2 opened on 5/1/2015 # 1pm and closed at 6pm.
WO #3 opened on 5/1/2015 # 2pm, closed # 3pm.
The system will calculate the total labor hours at 4 hrs for WO #1, 5 hrs for WO #2, and 1 hr for WO #3 for a total of 10 hours labor. In reality, the mechanic only did 6 hours of labor since the WO times overlap.
What I need is a formula(s) that will 1) point out where overlap occurs and 2) calculate the actual labor hours, not the system labor hours.
I'd like something that points out where overlap occurs and something that can count/return actual hours. This is easy enough to do in your mind on one-off basis, but I'm working with large data sets and doing these calculations manually is taking a ton of my time. I have played with MIN/MAX and SUMPRODUCT but I can't seem to get the formulas to return the results I'm looking for.
Sample data image for reference:
For your example, assuming start times/dates in B2:B6 and end times/dates in C2:C6 you can use this formula to get the total (non-overlapping) hours
=SUMPRODUCT((COUNTIFS(B2:B6,"<"&MIN(B2:B6)+ROW(INDIRECT("1:"&ROUND((MAX(C2:C6)-MIN(B2:B6))*1440,0)))/1440-1/2880,C2:C6,">"&MIN(B2:B6)+ROW(INDIRECT("1:"&ROUND((MAX(C2:C6)-MIN(B2:B6))*1440,0)))/1440-1/2880)>0)+0)/60
That shows the result as a decimal number of hours.
For that example I assumed you want to use the whole range - if you want you can add another criteria in to the formula to only calculate for a specific mechanic
The formula actually tests every minute within the time period to see whether it exists in one of the time periods, if so it's counted....but only once - see screenshot:
As to the second portion of your question, "calculate the actual labor hours, not the system labor hours", and assuming that the data is laid out something like this:
The formula could be =MAX(B2:C4)-MIN(B2:C4)
Need more information on how you want to show the "overlap", i.e. conditional formatting etc.

Resources