I am trying to trend the occurrence of a system event in Excel. I've attached a screen shot showing the pretty simple data that I'm working with.
The spreadsheet lists the times of the event (Column A) for a two week period and I've used a ceiling formula to group those events into 15 minute increments (Column B). Using a pivot table and chart, it's pretty simple to then take that data and graph the events into a line chart that shows the 15 minute increment time, and the count of the events in that 15 minute period.
Now I'd like to take subsets of that data and compare them. For example I'd like to compare Friday Saturday Sunday of last week Friday Saturday and Sunday of this week. So far, the only way I found to achieve this is to create duplicate pivot tables (Columns E, F and H,I), filter each table by the days I want to compare (25, 26, and 27 in one table and 1, 2 and 3 in the second), and then visually compare them (the Two charts).
But what I'd really like to do is to combine both series into one chart as a stacked line graph. I thought that would be pretty simple, but since the dates are so very dissimilar, I always wind up getting a single line or duplicate data, or totally off the wall results.
I've gotten kinda close by converting the row labels in to a custom DDD HH:MM format. That lists the Dates as (For Oct 25th)
Fri 00:15 11
Fri 00:30 1
Fri 00:45 4
Fri 01:00 3
Fri 01:15 6
Etc.
And (For Nov 1st)
Fri 00:15 7
Fri 00:30 1
Fri 00:45 2
Fri 01:00 1
Fri 01:30 2
Etc
Now I have something I can join on (Friday 00:15, 00:30, 00:45, etc is in both charts)
But the problem is, the two series often don't have the same Labels. For example the data for Nov 1 is missing 01:15,01:45 and 02:00 because no events occurred at those times. Same problem for the Oct 25th's data which is also missing 02:00 in addition to all increments between 02:30 and 03:45.
I tried just manually inserting the missing times in both charts but that quickly became a very complex and error prone chore.
So the question is: Is there a way to get excel to automatically fill in the missing time slots or am I completely off base in the way I'm trying to do this?
OK.. that was two questions :)
Thanks so much for your help!
Related
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.
I have data in two separate columns like this
But how can I count how many rows are occurring within say a window of 6 AM to 10 PM and outside a window of 10:01 PM to 5:59 AM?
The first column cells are formatted as General. The second column cells are custom h:mm:ss
Fuller View
Here I have a formula to count how many times "Mon" comes up in the left column
=COUNTIF($D:$D,"*"&$K5&"*")
And this is what I have when I try to combine the two to determine how many "Mon" entries were between 06:00 AM and 10:30 PM
=COUNTIFS($D:$D,"*"&$K5&"*",$E:$E,SUMPRODUCT((E2:E119>=M4)*(E2:E119<N4)))
but I get a fat 'ol zero
Yet if I run
=SUMPRODUCT((E2:E119>=M4)*(E2:E119<N4))
I get 116 as a return for the amount of times that a cell is between 06:00 AM and 10:30 PM
So BLUF - I want to count how many times a row has "Mon" and a corresponding time between 06:00 AM and 10:30 PM then I can replicate it for the rest of the days of the week.
New update-dtd 10/11/2022
Right now I know that there are 4 instances where Tuesday had after-hours calls:
Instance one was at 5:59 AM on the 11th
Instance two was at 5:57 AM on the 11th
Instance three was at 10:39 PM on the 11th
& Instance four was at 10:36 PM on the 11th
but with the formula of =COUNTIFS($D:$D,""&$K7&"",$E:$E,">="&$O$5,$E:$E,">"&$P$5)
I am only accounting for 2 of those instances - the 10:39 PM and the 10:36 PM instance (found this out by testing/removing the values in the cells to see what changed the total).
How would I capture the times that are between midnight and 05:59 AM, to include 5:59 AM?
#ScottCraner solved this with
=COUNTIFS($D:$D,""&$K5&"",$E:$E,">="&M4,$E:$E,"<"&N4)
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"
I've been working on this for awhile and can't seem to find an appropriate way to code this.
Goal: Take a list of monthly returns that currently spans over three years (this is an automated list so it will keep adding months) and find MTD, QTD, & YTD using function so I can automate the process.
Problem: I've tried the OFFSET function, different versions of COUNT, IF statements and can't find a way to properly code the function.
NOTE: this is for stock data/earnings report
Just to clarify, I know how to do this manually, but want to automate the process :) Would be more than happy to use VBA but would like to stick to a simple function if possible...
I'd be more than happy to email the WS to someone. Thanks so much!!
If you want to keep it simple and avoid vba here is a suggestion
The manner in which the data sheet is presented matters.
I assume months go down, with there only being 1 column for 'monthly returns'?
On a separate area/worksheet, set up the months with a value for what they are in the column next to them. Ie
Jan 1
Feb 2
Mar 3
Apr 4
...
Dec 12
then have a drop down where you can select what month it is.
so if it is Jul, you can select Jul.
From here, do a vlookup/indexmatch to pull the number for the month through, so Jul would be 7
From here the MTD is easy.
Do an offset from the beginning of the year to the current month
=offset ([start point],[month number],[columns])
=OFFSET($D$1,$C$21,0)
start point will be one row above Jan, that way when Jan is chosen it will fall onto Jan.
Month number you will get from what was said earlier
and columns will depend on how you place it
YTD, you will do the same as above but have a sum
so
=sum(B3:offset ([start point],[month number],[columns]))
=SUM(D2:OFFSET($D$1,C21,0))
QTD would be easiest just plotting the sums as it would never change
So set out Q1,Q2,Q3 and Q4 as prefixed ones. Then lookup to them.
However, if you want to see the most recent quarter by a formula. On the month number list add a new column which says what quarter it is. Then
Jan 1 1
Feb 2 1
Mar 3 1
Apr 4 2
...
Dec 12 4
It should the read off a formula like so
=SUM(
OFFSET([start point],(INDEX([month number table],MATCH([month],[month list],0),3)-1)*3,0):
OFFSET([start point],INDEX(month number table],MATCH([month],[month list],0),2),0))
=SUM(
OFFSET($D$2,(INDEX($F$2:$H$13,MATCH($C$20,$F$2:$F$13,0),3)-1)*3,0):
OFFSET($D$1,INDEX($F$2:$H$13,MATCH($C$20,$F$2:$F$13,0),2),0)
)
What you are doing is to find the month at the beginning of the quarter and then sum to the current month.
Regarding this bit at the end
OFFSET([start point],(INDEX([month number table],MATCH([month],[month list],0),3)-1)*3,0):
You are finding the month quarter index number(1,2,3,4) and multiplying it by three. The reason you want to take away one before multiplying by three is because you want the start point of the quarter, thus in jan to march, this will be 0, and then you add a row to get the start point being Jan.
In Oct to Dec this will be (4-1) = 3. 3x3 = 9 which will be Oct to make Oct being the start point. Amend as need be.
The yellow section is what your actual information is presented as
The green section is your lookup area
The Blue area is information you are looking for with the lower bit reading from the lookup
I have data which gives me the months and their respective weeks splitted.
I want to merge the cells as one for their respective months.
for example
my data is like this
july july july july july aug aug
1-7 8-14 15-21 22-28 29-3 4-10 11-17......
it should display as
july aug
1-7 8-14 15-21 22-28 29-3 4-10 11-17.....
both my month and weeks are generated dynamically, so, i cant say the exact position.
how i can calculate the position and merge the cells get it in macros in excel?
Somewhere on SE someone described merged cells (I think quite accurately) along the lines of “a creation of the Devil to try us beyond endurance”. Where used they could often be avoided by using Center Across Selection. In you case however I would suggest not bothering to find the position but merely blanking repeats after finding the first instance (therefore regardless of which month that is) which hopefully would make the code much simpler.