Excel - time of year/day/date/time to determine peak/offpeak - excel

I'm looking for a formula in excel that lets me know if a date each date/time is peak or off-peak (electricity use data). Peak/off-peak is determined by the season, day of the week and time.
Peak equals:
JUNE-SEPTEMBER (SUMMER)
- mon, tue, wed thurs, fri and hour 9:00-18:00
OCTOBER-MAY (WINTER)
-mon, tue, wed, thurs, fri and hours 8:00-21:00
Off-peak - All other hours. (ie where this is false)
I have the code to determine if something is off/on peak individually:
June-September
IF(AND(WEEKDAY(A2,2)<=5,WEEKDAY(A2,2)>=1,A2-INT(A2)>=0.375,A2-INT(A2)<=0.75),"peak","off-peak"))
October-May
IF(AND(WEEKDAY(A2,2)<=5,WEEKDAY(A2,2)>=1,A2-INT(A2)>=0.333,A2-INT(A2)<=0.875),"peak","off-peak"))
However, my problem is I don't know how to put these together with a date like
01/02/2019 09:00 to do the first step to determine if it qualifies as SUMMER or WINTER. Would this be workable with a nested IF in excel? I can't seem to get this.
Making a separate column with an If statement that shows if the date is winter or summer is easy, and I've done it. But I still don't know how to combine this with the above functions.
Many thanks.
Excel - day/date/time to determine peak/offpeak
I want the output to just tell me peak or off peak, but the variable hours depending on the time of year is tripping me up.

Yeah nested if statements. If you've got your formula for SUMMER/WINTER in A1, then nest like this:
=IF($A$1="SUMMER",IF(AND(WEEKDAY(A2,2)<=5,WEEKDAY(A2,2)>=1,A2-INT(A2)>=0.375,A2-INT(A2)<=0.75),"peak","off-peak")),IF(AND(WEEKDAY(A2,2)<=5,WEEKDAY(A2,2)>=1,A2-INT(A2)>=0.333,A2-INT(A2)<=0.875),"peak","off-peak")))

The WEEKDAY function is really MOD(<date>, 7) with some adjustments. Using MOD, anything less than 2 is Saturday or Sunday.
The HOUR function quickly converts true time to an integer that can be compared to a set of paramters which are adjusted for summer/winter.
=IF(OR(MOD(A2, 7)<2, HOUR(A2)<(9-ISNA(MATCH(MONTH(A2), {6,7,8,9}, 0))), HOUR(A2)>(18+ISNA(MATCH(MONTH(A2), {6,7,8,9}, 0))*3)), "off-", "")&"peak"

Related

WEEKNUM across multiple years

I am doing a cohort analysis for a subscription service from September 2021 - January 2023 and using the WEEKNUM formula, but of course each year starts on a different day and I am struggling to figure out how to mitigate this for all dates on the worksheet. Additionally, I just want there to be 52 weeks each year (not 53, week 52/1 can overlap years).
Presumably it will need to be some sort of IF statement but I just can't seem to visualise it!
I have tried =WEEKNUM(D2,15), which is fine for days in 2021 as it starting on a Friday, but not for days in 2022 and 2023 when I drag the formula down all of the dates
I think I've figured out the answer!
=IFS(D2<>"2023",(WEEKNUM(D2,1)),D2<>"2022",WEEKNUM(D2,16),D2<>"2021",WEEKNUM(D2,15))
I have tested it against some of the dates manually and it seems to hold true

How to use excel formula to proportionately distribute data

I am working on a task where i need to automate the calculation using formula in excel.
Below is the table;
Column A shows the hierarchy - Month(June) -> Week No(9,10,11,12,13) -> Days in respective Week(Mon - Sun)
Column B is sales. and Column C is the percentage break down.
I want to modify existing percentage break down in a new column in a way so that
more weightage is assigned to Thursday, Friday and Saturday and Sunday.
take out some percentage from Mon, Tue and Wed and assign them to Thu, Fri, Sat and Sun.
New percentage should should add up to respective weeks percentage.
Below is the formula i used;
=IF(A81="Mon",C81-0.005,IF(A81="Tue",C81-0.005,IF(A81="Wed",C81-0.005,IF(A81="Thu",C81+0.003,IF(A81="Fri",C81+0.004,IF(A81="Sat",C81+0.006,C81+0.002))))))
Challenge arises when weekdays are split between 2 months. For example, if you look at week 9(Jun) - it starts from Wed while Mon and Tue are part of May.
Here is the outcome I got with current formula;
In calculated field sum of new percentage(17.99%) is not same as earlier(16.99) which is wrong.
Can you please help me create a formula which takes care this challenge and fulfil other conditions as well.
I would really appreciate your help.
Thanks.

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

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.

How to convert Excel date/time to epoch

I Googled and found a formula that is supposed to convert from Excel date/time to epoch time. However, it's off (or I'm off) and I can't figure out what I'm doing wrong. I'm using http://www.epochconverter.com/ as my source of truth.
So the link I found says the formula is:
=(A1-25569)*86400
I think 25569 is the Excel value for DATEVALUE("1-1-1970") but for some reason my version of Excel says that's 24107 so I made some modifications and typed:
=((A2-DATEVALUE("1/1/1970"))*86400 - 8*3600 (for PST)
Now the number is a little more correct. However, it seems like I need to ADD 8*3600 instead of SUBTRACT.
Can someone explain to me why?
I thought PST is -8 from GMT.
For the sake of an answer:
Your Excel is using the 1904 date system.
IF your Excel times start off as ‘local’ don’t adjust for time zone. IF they start as GMT (a concept Excel does not have) then, because when a GMT clock ticks on to 16:00 a ‘local’ clock should tick on to 08:00, from Excel to ‘local’ means deducting 8 hours. Note that midnight 31/12/1969 is not the same instant GMT as PST.

How do I use the "If" function with hh:mm?

I am trying to use the IF function with the hh:mm format. The objective is to reduce a calculated time by 30 mins IF the total time is equal to or over 9 hours.
Here is the formula I was trying to use, but it doesn't work:
IF(time(hour(T3),minute(t3)<=9, -0,TIME(HOUR(T3), MINUTE(T3) - 30, SECOND(T3))).
Any suggestions would be appreciated.
Thank You.
Date values in Excel are in fact numeric - to put it short it's number of days since January 1, 1900. I.e. 41948.5 means 05 November, 2014 12:00. So one hour equals to 1/24=0.041666.... In your case:
=IF(MOD(T3,1)>=9/24,T3-0.5/24,T3)

Resources