Trying to show a full years amount based on a smaller fraction of the year's total - excel

this is my first post.
Right now, I have a limited set of data ranging from the beginning of this financial year until now. I'm trying to show what a full year's worth of that data would look like.
For example, if the number is at 10, and the data range is from 1/07/2021 - 30/12/2021 (half the year), then the end output should be 20. Or for example, turn a 12 with 3/4 of the year date range to 16 for a full years' worth.
However, my current formula would end up with 15 (10 + "half") rather than (10 + 10)
Right now this is what I have, but I know there's something off on my logic, as the output is smaller than it should be:
D1+((364-(F1-E1))/365)*D1
where E1 is the start date and F1 is the end date, and d1 is the number for that date range
Thanks in advance

endDate - startDate will give you the number of days the data covers.
(endDate - startDate) / 365 will give you what fraction of a year the sample represents.
Let’s say this works out to be 30%, or 0.30.
annualValue * 0.30 = periodValue and therefore we know that periodValue / 0.30 = annualValue.
So there it is, the cell you want the Annual Value in should be:
= periodValue / ( ( endDate - startDate) / 365 )
I will leave it to you to replace each of the three named values in my example to be the correct cell references. I suspect that’s probably:
=D1/((F1-E1)/365) which is the same as (D1*365)/(F1-E1).
The easy way to remember this is that it’s just cross-multiplication.
periodValue / days is proportionate to annualValue / 365. Thus periodValue / days = annualValue / 365. Cross-multiply and you get periodValue * 365 = annualValue * days. Divide both sides by days and you get `annualValue = (periodValue * 365)/days.

Related

Simple(r) Excel formula to calculate forward stock (inventory) cover

This is a perennial question for retailers, for which there are a number of solutions in existence:
How can you calculate the "forward cover" of a product knowing its current inventory and armed with forward sales estimates.
eg.
current inventory 100 units (cell A1)
weekly forward sales estimates: 25, 30, 10, 40, 90... (in range
A2:AX)
Here the answer would be 3.875 weeks (3 full weeks plus 0.875 of week 4)
I have a UDF to do this already.
I also have some slightly complicated array functions to do this, eg.
=MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1+(A1-SUM(A2:INDEX(A2:A13,MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1)))/INDEX(A2:A13,MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1+1)
I was wondering if there is a neater way with these 'new-fangled' array functions which have been available for the last few years in later versions of Excel?
Here is another possible solution, although it requires the LET() function which is only available to newer version of excel (2021, 365 and later I believe).
The solution would be the following formula:
=LET(
sales,A2:A50,
inventory,A1,
cum_sum,MMULT(SEQUENCE(1,ROWS(sales),1,0),(ROW(sales)<=TRANSPOSE(ROW(sales)))*sales),
week_full,MATCH(TRUE,inventory<cum_sum,0) - 1,
week_frac,(inventory - INDEX(cum_sum,week_full)) / INDEX(sales,week_full + 1),
week_full + week_frac
)
Explanation
Given inventory and the forward looking sales estimates, the formula calculates the running total (i.e. cumulated sum) of the sales estimates as shown in the table here below
Inv and Sales
Cumulated Sum
Inv > Cum_Sum
Week
100
25
25
0
1
30
55
0
2
10
65
0
3
40
105
1
4
90
195
1
5
...
...
1
6
The formula goes on to get the number of full weeks of 'forward cover' by finding the the value for the cumulated sum that exceeds the inventory minus one (here 4 - 1 = 3).
Lastly, for the value of the week fraction covered in the last week, the formula calculates inventory minus sum of sales estimates of all previous weeks divided by sales estimate of final week of cover (i.e. (100 - 65) / 40 = 0.875).
Edit
After simplifying the formula you used with the LET() function, I noticed it's doing exactly the same calculation with the only difference of how the cumulated sum is being calculated. Here's your formula using LET():
=LET(
sales,A2:A50,
inventory,A1,
cum_sum,SUBTOTAL(9,OFFSET(sales,,,SEQUENCE(ROWS(sales)))),
week_full,MATCH(TRUE,cum_sum>inventory,0)-1,
week_frac,(inventory - INDEX(cum_sum,week_full)) / INDEX(sales,week_full+1),
week_full + week_frac
)
=LET(inv,A1,
sales,A2:A6,
cs,SCAN(0,sales,LAMBDA(x,y,x+y)),
m,XMATCH(A1,cs,1)-1,
m+(inv-
IF(m=0,
0,
INDEX(cs,m)))
/INDEX(sales,m+1))
SCAN() is perfect for creating a cumulative sum.
It can be referenced inside XMATCH because of the use of LET.
Here m returns the number of full weeks and the final calculation is the number of full weeks + (inv- cumulative sum up to the full week)/sales of the following week.

Formula to Calculate Subscriber Churn Revenue

I'm trying to sum up 12 months of subscriber revenue factoring a 6% monthly churn (assuming no signups) to come up with the one-year value of a subscriber. A simple future value gives me the start and end values, but I'm looking to get the sum of the monthly declining revenues in a single Excel / Google Sheets formula. I can make 11 entries (plus the starting month full value), but is there a better one-liner or formula for this?
This gives me the 12th-month revenue:
=FV(-6%,11,0,100)
I'd like to get the sum without this:
=100 + FV(-6%,1,0,100) + FV(-6%,2,0,100) ... FV(-6%,11,0,100)
You are looking for the sum of a finite geometric series:
1 + r + r^2 + r^3 .... + r^11
And the sum of this series is
(1 - r^12) / (1 - r)
where r = 1 - 6%
So the formula would be
= (1 - (1-6%)^12 ) / (1 - (1-6%) ) * 100
This is assuming the OP meant
=100 + FV(-6%,1,0,-100) + FV(-6%,2,0,-100) ... FV(-6%,11,0,-100)
as FV(-6%,1,0,100) would output a negative number
I don't know much about such math but would the following formula give you the result?
=100+SUMPRODUCT(FV(-6%,ROW(1:11),0,-100))
The formula works in both Excel and Google Spreadsheets

How to count hours in excel

I have xls file in following format
Name 1 2 3 4
John 09:00-21:00 09:00-21:00
Amy 21:00-09:00 09:00-21:00
Where 1,2,3,4 and so on represent days of current month,
09:00-21:00 - working hours.
I want to calculate salary based on the following conditions:
09:00-21:00 - 10$/hour
21:00-00:00 - 15$/hour
00:00-03:00 - 20$/hour
etc.
and so on (every hour can have it's own cost, for example 03:00-04:00 - 20$/hour, 04:00-05:00 - 19$/hour, etc.)
How can i accomplish this using only Excel (functions or VBA)?
P.S. Easy way: export to csv and process in python/php/etc.
Here is a non-VBA solution. It's a pretty nasty formula, but it works. I am sure it could be made even easier to use and understand with some more ingenuity:
Assuming the spreadsheet is set up like this:
Enter this formula in cell G1 and drag down for your data set:
=IF(ISBLANK(B2),"",IF(LEFT(B2,2)<MID(B2,FIND("-",B2)+1,2),SUMIFS($P$2:$P$24,$Q$2:$Q$24,">="&LEFT(B2,2),$Q$2:$Q$24,"<="&MID(B2,FIND("-",B2)+1,2)),SUMIF($Q$2:$Q$24,"<="&MID(B2,FIND("-",B2)+1,2),$P$2:$P$24)+SUMIF($Q$2:$Q$24,">="&LEFT(B2,2),$P$2:$P$24)))
To explain the formula in detail:
IF(ISBLANK(B2),"" will return a empty string if there is no time for a given person / day combination.
LEFT(B2,2) extracts the start-time into an hour.
Mid(B2,Find("-",B2)+1,2) extracts the end-time into an hour.
IF(LEFT(B2,2)<MID(B2,FIND("-",B2)+1,2) will check if the start-time is less than the end-time (meaning no over-night work). If the start-time is less than the end-time, it will use this formula to calculate the total cost per hour: SUMIFS($P$2:$P$24,$Q$2:$Q$24,">="&LEFT(B3,2),$Q$2:$Q$24,"<="&MID(B3,FIND("-",B3)+1,2))
If the start-time is higher than the end-time (meaning overnight work), it will use this formula to calculate: SUMIF($Q$2:$Q$24,"<="&MID(B3,FIND("-",B3)+1,2),$P$2:$P$24)+SUMIF($Q$2:$Q$24,">="&LEFT(B3,2),$P$2:$P$24)
The use of the Find("-",[cell]) splits the start-and- end times into values excel can use to do math against the Time / Cost table.
The formula in column Q of the Time / Cost table is =VALUE(MID(O2,FIND("-",O2)+1,2)) and turns the ending hour to consider the cost into a value Excel can use to add, instead of having the text from your original source format.
Do this in VBA! It is native to excel and is easy to learn. Functionally, I would loop through the table, write a function to calculate the dollars earned based on the info given. If you want your results to be live updating (like a formula in excel) you can write a user defined function. A helpful function might be an HoursIntersect function, as below:
Public Function HoursIntersect(Period1Start As Date, Period1End As Date, _
Period2Start As Date, Period2End As Date) _
As Double
Dim result As Double
' Check if the ends are greater than the starts. If they are, assume we are rolling over to
' a new day
If Period1End < Period1Start Then Period1End = Period1End + 1
If Period2End < Period2Start Then Period2End = Period2End + 1
With WorksheetFunction
result = .Min(Period1End, Period2End) - .Max(Period1Start, Period2Start)
HoursIntersect = .Max(result, 0) * 24
End With
End Function
Then you can determine the start and end time by splitting the value on the "-" character. Then multiply each payment schedule by the hours worked within that time:
DollarsEarned = DollarsEarned + 20 * HoursIntersect(StartTime, EndTime, #00:00:00#, #03:00:00#)
DollarsEarned = DollarsEarned + 10 * HoursIntersect(StartTime, EndTime, #09:00:00#, #21:00:00#)
DollarsEarned = DollarsEarned + 15 * HoursIntersect(StartTime, EndTime, #21:00:00#, #00:00:00#)
I have a method that uses nothing but formulas. First create a lookup table which contains every hour and rate in say columns K & L, something like this:
K L
08:00 15
09:00 10
10:00 10
11:00 10
12:00 10
13:00 10
14:00 10
15:00 10
16:00 10
17:00 10
18:00 10
19:00 10
20:00 10
21:00 15
22:00 15
23:00 15
Make sure you enter the hours as text by entering a single quote before the digits.
Then if your hours were in cell B2 you could then use this formula to calculate the total:
=SUM(INDIRECT("L"&MATCH(LEFT(B2,5),K2:K40,0)&":L"&MATCH(RIGHT(B2,5),K2:K40,0)))
All the formula is doing is getting the left and right text of your work time, using MATCH to find their positions in the lookup table which is used to create a range address which is then passed to SUM via the INDIRECT function.
If you need to worry about minutes all you need to do is create a bigger lookup table which holds every minute of the day. You may need to add some extra logic if your work days span midnight.

Working Hours Excel Formula

I need to calculate the working hours elapsed between two dates and times, for example:
Holiday taken between 01/09/2014 and 05/09/2014
5 working days # 8 hours per day.
I need the result to show me how many working hours that would be. For example:
ANNUAL ENTITLEMENT: 89.9 Hours
DATE FROM DATE TO RETURN TO WORK HOURS REQUIRED HOURS REMAINING DATE
01/09/2014 05/09/2014 06/09/2014 40 49.90
I have no idea if this is even possible!
I am assuming these are given cells. if you type in the date to a cell you can click on a new cell and put uptop by the fx this
for example. In C1 you can type this into the fx. Make sure you put the equal sign.
=B1-A1
This is what is the dates in the cells
A1 = 1/9/2014
B1 = 5/9/2014
This will give you 120 which is the total days inbetween.
You will want to get the number of weeks so you can divide by 7.
You will multiply weeks by number of days worked which is 5
Then you want the weeks times 8 hours you can do this in C1
=(B1 - A1)/7 * 5 * 8
which gives you 685.7143
you need to also take into account weekends which a simple subtraction will not do. Firstly find the total number of days:
TOTAL_NUMBER_DAYS = B1-A1 + 1
then calculate how many weekends:
TOTAL_WEEKENDS = WEEKNUM(B1) - WEEKNUM(A1)
finally take the total days and subtract weekends:
NET_TOTAL_DAYS = TOTAL_NUMBER_DAYS - (TOTAL_WEEKENDS * 2)
TOTAL_HOURS = NET_TOTAL_DAYS * 8
I solved this recently and had a working solution initially in Excel 2013. Slightly adapted to work in 2007 (lack of 'Days()' function). We use it for reporting on support tickets (length of time between opening and closing a ticket).
Inputs are "Workday start", "Workday end" from which "Hours worked" and "Hours not worked" are calulated.
Hours worked =HOUR(WorkEnd-WorkStart)+(MINUTE(WorkEnd)+MINUTE(WorkStart))/60
Hours not worked = 24 - Hours worked
Further inputs are a table ("Data") with first two columns "Open" and "Close", which are dateserial cells.
Next column is standard numeric value "Gross hours" =(Data[[#This Row],[Close]]-Data[[#This Row],[Open]])*24
Next column is standard numeric value "Net workdays" =NETWORKDAYS(Data[[#This Row],[Open]],Data[[#This Row],[Close]])
Next column is standard numeric value "Net days" =MAX(1,DAY(Data[[#This Row],[Close]])-DAY(Data[[#This Row],[Open]]))
Next column is standard numeric value "Gross workhours" =IF(Data[[#This Row],[Gross hours]]>0,Data[[#This Row],[Gross hours]]-24*(Data[[#This Row],[Net days]]-Data[[#This Row],[Net workdays]]),0)
Last column is standard numeric value "Total work hours" =IF(Data[[#This Row],[Gross workhours]]<24,Data[[#This Row],[Gross workhours]],Data[[#This Row],[Gross workhours]]-(HoursNotWorked*Data[[#This Row],[Net workdays]]+HoursWorked))
This solution makes it trivial to adjust start and end work times, as well as accounting for any holidays (via a small change to the NETWORKDAYS() function to utilise the optional parameter).

Formula to calculate salary after x year?

Knowing that i am getting paid $10 000 a year, and that each year my salary increase by 5%.
What is the formula for Excel to know how much i will get in 5 year?
Thank you for any advise
The formula in Excel is:
=VF(5%;5;0;-10000)
Which results in: $12,762.82
If your Office is english version you can use:
=FV(5%;5;0;-10000)
=(10000*((1 + 0.05)^5))
The Compound Interest Equation
P = C (1 + r/n)^nt
Where...
P = Future Value
C = Initial Deposit/Salary
r = Interest Rate/Pay Increase (Expressed as a Fraction: EX = 0.05)
n = Number of Times per Year the Interest/Pay Raise Is Compounded (0 in Your Example)
t = Number of Years to Calculate
The Formula is POWER(B1,C1)*10000, and the cell B1 is (1+5% ), the cell C1 is the number of years
current = 10 000
for each year -1
current = current * 1.05
end for
current now has current salary for the given number of years

Resources