How to calculate a... median? of hour/day/month of occurence? - excel

My problem concerns day of month however, I can see that the same logic would apply to month number or hour number or any other variable that ends on some value and then starts from 0 again.
It is defined as follows: I'm trying to calculate a day of month when a payment is made to use it for a forecast. So I have for example for one case:
1 May 2016
2 June 2016
30 June 2016
29 July 2016
6 September 2016
A simple average would give me 14th, and the median would give me 6th. But the result I'm looking for is more like the 1st.
I see I could do it somehow by calculating geometric median, or euclidean distances after placing the points on a circle etc, but I believe it can be approached in a much simpler way. I also see that solving this problem with standard means and averages would cause a situation where it gives more than one result.
But if we add an assumption that it should occur once in 30 days/a month? Wouldn't this assumption make the problem easier?
Please let me know if you solved a similar problem before or if you have any ideas

If the result you are "looking for is more like the 1st", then I would hazard a guess that you are really looking at a series of monthly payments (perhaps falling due on the first of each month or the first working day of each month) and you want some measure of the deviation between the due date and the actual date of payment.
If that is the case then simply calculate the difference in days between the due date and the actual date of payment for each monthly payment (following a consistent convention such as positive values denote late payment and negative values are early) and then apply your chosen measure (median, mean, etc) to the series of differences.

Related

How to display the past 17 trading days (business days) when looking up Stock History in excel

I'm using the new STOCKHISTORY function in Excel and I'd like to always display the past 17 trading days from the point I indicate. The problem is with long weekends and holidays this alters the amount of business between two dates. I'm not sure if this will be a difficult question because I think the solution is not dependent on the fact that I'm using the STOCKHISTORY function. I have attached a photo with a simple explanation. On the left the formula for STOCKHISTORY is =STOCKHISTORY(E2,C4-C6,C4,0,1,0,2). This displays 17 business days because 22 is the magic number. On the right though if I query July 22nd with 22 day difference I only get 16 days. This is further wrong on many other dates.
I am open to having a separate reference on another sheet that has dates/formulas. I tried this but couldn't figure out a formula to pull down. Photo B displays an example of the correct number of dates that would show 17 trading days. I am also open to displaying more than 17 trading days as in the future I will need to alter the amount of trading days needed (I might need to display 15 days or 20 days).
In my head I feel like the answer has something to do with the NETWORKDAYS function and/or I should make a list of all the trading days in a year and then make a formula taking the current day and taking away a specific day. Or I could be totally wrong and the answer is obvious.
So I figured out an answer after reading some documentation. There is most likely better answers but it solves the problem enough.
So I created a list of all trading days (business days) as you can see in column O. Then in Column L a list of nearby holidays (Only needed a few exceptions). Then using the formula =(O35)-(WORKDAY(O36,-17,$L$35:$L$36)) I get the right solution which I verified in my example photo posted earlier. You could theoretically get a different number when doing your own calculations (i.e the answer 24 and 23 are both correct).

Excel - SUMIF Function

I made a worksheet covering meal expenses for a set period of time (01-08-2020 until 31-08-2020.)
The company will pay up to 75kr, Monday-Friday.
The list covers expenses 7 days a week, If the amount is greater than 75 on Monday-Friday, I have to pay the extra expenses. (This I have figured out correctly). Saturday and Sunday I have to pay fully.
So my question is, how can I sum this and exclude Saturday and Sunday?
Attempt 1:
I tried this formula (Norwegian excel. Summerhvis = SUMIF. Lørdag = Saturday):
=SUMMERHVIS(B2:B32,"<>lørdag", G2:G32)
It seems to be partly correct however, I miss Sunday, how can I add Sunday to this equation?
Attempt 2:
I used this formula:
=SUMMERHVIS(B2:B32,B2:B6,G2:G32)
It gave the correct answer but the answer was layered in 5 rows. I then summed this in P8.
Where I want the answer is in G32. So in G32 I wrote =p8.
It must be an easier way of doing this?
You can use SUMPRODUCT and the WEEKDAY function:
=SUMPRODUCT((WEEKDAY(A2:A32,3)<5)*G2:G32)
According to the Microsoft function translator, this might be, in Norwegian:
=SUMMERPRODUKT((UKEDAG(A2:A32;3)<5)*G2:G32)
If you really want to use SUMIF and your text days, one way would be (in English):
=SUM(SUMIF(B2:B32,{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday"},G2:G32)),
or, if your weekday days are in b4:b8:
=SUM(SUMIF(B2:B32,$B$4:$B$8,G2:G32))
but I'd advise against it as it would only work in the language of the text days of the week. Also, I note your days of the week don't seem to match up with what the days of the week were in the US. For example, here 1 Aug 2020 was a Saturday, so another possible cause for error (unless I am not understanding the dates correctly).
The above is the same as summing five separate SUMIF equations, each for a desired day of the week.

How to create exponential growth in excel over a year

So I am trying to build an excel model where every month the numbers will increase exponentially to a point at the end of the year which is driven by annual expectations. Currently I have it divided by 12 and each year there are huge jumps over the previous making the chart/growth very jumpy. For illustration purposes, lets say for 2020 the desired number for the year is 12. In the current state, I would get 1 per month (12/12), however, what I want is for it to be growing gradually/exponentially, so for example 0.2, 0.5, 0.9 etc with December being the largest, and the sum for the entire year equaling 12. Then the next year (2021), starting in January, it would take into account the December 2020 number and grow from there again to the desired number (lets say total 24 for 2021) and so on. I'd love for it to have a more exponential / hockey stick-like growth.
What would be a good way to do this?
The function RRI can be used to find an interest rate which will give you a given target value. This can be used to find terms in a geometric series which have a given sum (which is what you seem to be asking for).
For example, say you want 12 exponentially increasing numbers which, when added to 100, gets you to 2000. Starting with 100, repeatedly multiply by (1 + RRI(12,100,2000)). To get the numbers that you want (which will be 12 numbers which sum to 1900) just calculate the difference each month:
I think the simplest way to solve this is by using Goal Seek. First you need to build a sheet like this:
You choose the starting value in January (B1) and every month is a constant growth rate (D1) bigger than the previous month. You also calculate the total sum at the bottom in B13.
Now you use goal seek to find the growth rate which makes the sum equal to 12:
The answer I get for a starting value of 0.1 is a growth rate of 1.376:

Calculate annual leave between two dates in Excel

This task seems easy enough yet I just can't figure a way of doing this without resorting to vba.
All I need is to know the number of hours an employee has used up on annual leave, based on a start and end date, and their hours of work.
To be more clear, this example shows one employees contracted hours from Monday to Sunday i.e. they work only Weds, Thurs, and Friday, for 7.5 hours each day.
Below shows the start and end date that the employee has chosen to take for annual leave. I need to calculate, based on their contracted hours, how much annual leave is used between the two dates. The answer would be 45 hours in this case.
Here's another approach - I've expanded the days between the start and end dates into an array then used the resulting day numbers to offset into the days of work range
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1)))
If you had a list of holiday dates somewhere (say in I3:N3) you could exclude them as follows
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1))*ISNA(MATCH(ROW(INDIRECT(A6&":"&B6)),I3:N3,0)))
- it is a bit long-winded but the only way I can think of at the moment.

Excel Trend Projection

I'm trying to find a trend projection that compares between same week of 2 consecutive years and also from previous weeks of a particular year. What is the excel formula that helps me to do this?
I need to find the projected values for week 15 all the way to week 53 for This year, based on
The previous weeks of This year (Week 1- Week 14) as well as
The same week Last year (Week 15)
You could use the Trend function, setting Known X's to Last Year weeks 1 to 14 and Known Y's to This Year weeks 1 to 14.
Then set the New X's to the same week for last year and the function will use the Least Squares method to extrapolate for this year.
If you use absolute references (e.g. $A$1:$A$10) for the Known X's and Y's, and a relative reference for the New X's, then you can just copy/paste the formula from This Year week 15 down.
Keep in mind though that the further you get from the Known values, the less accurate the forecast becomes...
Are you familiar with the add-in solver or Data Analysis? Sometimes you have to unhide it by going to options>add-in>"Data Analysis" to use it but it does simple analyses. You will find several helpful tools for doing stats in "Data Analysis."

Resources