Missing hours in Excel - excel

I have a weather data in Excel taken every hour for 2008. Year of 2008 had 366 days thus 8784 hours. However, I noticed that there are 8767 rows and therefore 8784 - 8767 = 17 hours are missing. Unfortunately, I don't know which hours are missing throughout the whole year. I also have an extra column which displays the date along with the time in the format of "day-month-year time". E.g. 31-12-08 23:00.
Is there any method in Excel so the missing hours can be added as an extra row?
Thanks

Simply subtract one datetime from the previous one, if the answer is not 1 hour - then you know where the missing rows are. You can use a simple IF function for this, e.g.
=IF(HOUR(A2)-HOUR(A1)=1,"","Missing")
Of course, you need to copy this formula down a column so that it checks all the rows.

You can insert rows using a VBA macro, but there is an easier way without macros. Start a brand new worksheet. In A1 enter:
=DATE(2008,1,1)+TIME(0,0,0)
In A2 enter:
=A1+TIME(1,0,0)
and copy down. With proper formatting this will look ike:
This will be a complete set of date/times. At this point you can pick-up data from your original worksheet using VLOOKUP() or MATCH() / INDEX()
This will also allow you to identify the missing rows.

Related

How to build accumulated sum per day in Excel?

I have an Excel worksheet where I write down all the hours per day I work on my project.
During one day I just work some minutes here and there.
In one column of my sheet I would like to have the accumulated / added hours I worked at that specific day.
So once a row with day, start, and end is complete, the referring accumulated hours per day for this new row should appear.
I would like to have this cell prefilled, so that I do not have to make any manual adjustments of the contents of this cell.
How has a formula in column accumulated hours per day have to look like to achieve this?
You're looking for this:
=IF(A2<>A1,0,D1)+C2-B2
Ideally, I'd suggest avoiding references in the over row by using OFFSET. Try this instead:
=IF(A2<>OFFSET(A2,-1,0),0,OFFSET(D2,-1,0))+C2-B2
I would suggest creating a pivot table and there you can do many things.
You could also try an array formula version:
=SUBTOTAL(9,OFFSET(C2,0,0,ROW(A2:A9)-1))-IFERROR(SUBTOTAL(9,OFFSET(C2,0,0,MATCH(A2:A9,A2:A9,0)-1)),0)-
(SUBTOTAL(9,OFFSET(B2,0,0,ROW(A2:A9)-1))-IFERROR(SUBTOTAL(9,OFFSET(B2,0,0,MATCH(A2:A9,A2:A9,0)-1)),0))
or more dynamically using Excel 365 Let and Sequence:
=LET(range,A2:INDEX(A:A,COUNTA(A:A)),r,ROWS(range),
SUBTOTAL(9,OFFSET(C2,0,0,SEQUENCE(r)))-IFERROR(SUBTOTAL(9,OFFSET(C2,0,0,MATCH(range,range,0)-1)),0)-
(SUBTOTAL(9,OFFSET(B2,0,0,SEQUENCE(r)))-IFERROR(SUBTOTAL(9,OFFSET(B2,0,0,MATCH(range,range,0)-1)),0)
))

excel count sets of dates that date is between

Here is my data model: I have an excel sheet with each row representing a date range (an event). There is significant overlap. A2 might be 4/10/15, and B2 might be 4/12/15; while A3 might be 4/11/15 and B3 might be 4/12/15.
I am trying to get a count for each day of the year 2015 how many events occurred on that date. with my limited "for instance" I would get something like:
4/9/15 0
4/10/15 1
4/11/15 2
4/12/15 2
4/13/15 0
I have some sudo code for this if I were to just save the set as a csv and use java or something to grab each date and create an object but I find it hard to believe that excel is not capable of this on it's own.
We tried a wild number of countif and countifs statements but I am really just at a loss when it comes to excel.
I thought I was close with this:
=COUNTIF(Sheet2!A2,AND(Sheet2!A2>=(dates!B*), Sheet2!A2<=(dates!C*)))
but in order to get that to work I would need it to iterate through each row of dates and I am just not sure how to do that.
Any help is appreciated. As a backup plan I am refining my sudo-code for a possible vb excel script (never done that before) or just breaking it out into java and using the old text edit scripts I haven't had to touch since college labs.
Thank you for any help.
Your keyword is COUNTIFS
Say your criteria day is in cell Sheet2!A2 and your event ranges are in sheet Dates columns B and C; Try this formula:
=COUNTIFS(Dates!B:B, "<="&Sheet2!A2, Dates!C:C, ">="&Sheet2!A2)

SUMPRODUCT several ifs

I´ve spent a lot of time with a formula in Excel and I´m still blocked. I hope you can help me.
I have a table in Excel with several values as shown in this
screenshot.
What I´m trying to extract is the number of Fruits sold in a specific month. That is, how many lemons were sold in January 2016, for example. This is the formula I´m using:
=SUMPRODUCT((B3:B38=E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
But the result is #N/A as seen in the screenshot.
What Am I doing wrong? Any help, please?
Thanks a lot in advance!
You can use arrays in excel to get this answer
{SUM(IF(MONTH(F$3&"1")=MONTH($A$3:$A$150),IF($E4=$B$3:$B$150,$C$3:$C$150,0),0))}
You can use this Sumproduct formula which uses array logic:
SUMPRODUCT((MONTH($A$3:$A$38)=MONTH(TEXT(G$2,"MMM")&1))*($C$3:$C$38=$F4)*
($D$3:$D$38))
Sumproduct Demo
Part of your problem is your ranges are not equal in length. B3:B38 has to be the same number of rows as $A$3:$A$150 and C3:C150. When rows are not equal things blow up on you.
=SUMPRODUCT(($B$3:$B$150=$E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
if you change your header row to be actual excel date format, and then change the cell display format to just show the month (as suggested by csanjose), then you can adjust your sumproduct formula as follows and copy to all cells in your table.
=SUMPRODUCT(($B$3:$B$38=$E4)*(MONTH($A$3:$A$150)=Month(F$3))*(YEAR($A$3:$A$150)=Year(F$3));$C$3:$C$150)
Fill your month-row with the last day of each month, then apply date format to show only month name.
The formula you should use is, for example, in g8:
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&G$3;$A:$A;">"&F$3)
First column "F" doesn't have a column on the left to compare, so you can put a date in E3 or change a bit the formula (example of F8):
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&F$3;$A:$A;">2015/12/31")
Take a look at the result
If you don't want to use a pivot table, you can use this formula to get what you need:
=SUMPRODUCT(($B$3:$B$150=$E3)*(MONTH($A$3:$A$150)=1)*(YEAR($A$3:$A$150)=2015)*$C$3:$C$150)
Then drag-fill the cell to copy it to every month column (just make sure you change the month number in the formula (and year if you're doing that too)), and then drag-fill down the columns.
That should work pretty food good :)
Good Luck!

Excel Match function with concatenated value

I am somewhat new to writing large, complicated formulas with excel. I took over a report from someone about 7 months ago and it seems that every week I find issues with what was written with his formulas.
This week I am having issues with a match formula. We have a report we run for a big hardware store and they report based on weeks. This last week was 201501 (2015, week 1.) Last week was 201452 (2014, week 52.)
To look at 4 week sales averages, my predecessor setup 4 numbers that would change every week based on the week you type in one of the column headings. So, when I type 201452,
#1 is 201449
#2 is 201450
#3 is 201451
#4 is 201452
He feeds those into a match function.
I found this week that 201501 does not correctly display the weeks. I got
Results Formula Used
201501 =D1 (The cell where you type the Store's week)
201500 =IF(M1=201301,201252,IF(M1=201401,201352,M1-1))
201499 =IF(L1=201301,201252,IF(L1=201401,201352,L1-1))
201498 =IF(K1=201301,201252,IF(K1=201401,201352,K1-1))
I changed those formulas
Results New Formula
201501 =D1
201452 =IF(RIGHT(M1,2) = "01",(LEFT(M1,4) - 1)&"52",M1-1)
201451 =IF(RIGHT(L1,2) = "01",(LEFT(L1,4) - 1)&"52",L1-1)
201450 =IF(RIGHT(K1,2) = "01",(LEFT(K1,4) - 1)&"52",K1-1)
However, the match formulas he has setup throughout the workbook have not been fixed. They are still displaying "#N/A." One such formula is
=INDEX(N5:DZ5,1,MATCH(Data!$L$1,$N$1:$ED$1,0))
This formula basically looks at the column headers, and if it sees that the column header matches the week I've typed, will display the value within that range.
Basically, any formula that's being fed the 201452 value is returning "#N/A". The other numbers miraculously display data.
I've already tried converting all of my data in the affected rows to "General" format type. I've tried checking to see if I have spaces before or after in all of my formulas and column headers, but am still having no luck.
Any ideas?
After trying and trying and trying, I found that Excel does not like the concatenation. Trim does not help, Text does not help, Concatenate of course did not work.
I ended up realizing I could simply write
=IF(RIGHT(M1,2) = "01",M1-49,M1-1)
This makes it so that in the instance where the number to the right of it is the first week, subtract 49 days and produce 52 instead of 00.
I'm guessing here, but it could be that your formulas are presenting the Year/Week combo as a number, where the Match formula is looking for text (for Excel's purpose, it doesn't recognize them as the same).
You can get around this, by wrapping your formulas above with the text formula
So you'd have the following:
Results New Formula
201501 =TEXT(D1,"0")
201452 =TEXT(IF(RIGHT(M1,2) = "01",(LEFT(M1,4) - 1)&"52",M1-1),"0")
201451 =TEXT(IF(RIGHT(L1,2) = "01",(LEFT(L1,4) - 1)&"52",L1-1),"0")
201450 =TEXT(IF(RIGHT(K1,2) = "01",(LEFT(K1,4) - 1)&"52",K1-1),"0")

Counting Cells in a Range that Contains Formulas, Only when a Date is Returned?

Frequent browser, first time poster. Please go easy:
I have spent the last few days searching online, and on here for a solution to a problem I have encountered for the first time. I have a report that pulls from multiple worksheets. One column is a formula that does a VLOOKUP to another sheet and pulls back a date, if it exists. I then have a cell at the top of the sheet that calculates how many dates are pulled back out of all of the rows (to calculate % complete). This is where I am having the problem. I have tried variations of COUNTIF, COUNTA, COUNTBLANK, and so on, and formulas trying to reverse calculate,
=SUM(C4)-COUNTIF(Table3[2014 Process Date],"")
At first it appeared to work, but in this example, I had 1949 rows, and dates only populated in 7 of those rows. In theory it should return 7. Instead it is returning 237. I have done multiple filters, and manually reviewed the data in the column, and only 7 dates are there. The column has the VLOOKUP in and IFERROR nest,
=IFERROR(VLOOKUP(A12,Table_TaxData.accdb3[#All],240,FALSE),"").
I am guessing I am overlooking something silly, and was hoping someone would be able to help steer me in the right direction, or let me know what I am missing. Thanks in advance for any help!
Wow, looks like I need some more coffee! Thank you, I guess I assumed that it would be much more complicated than that. I just threw in
=COUNT(Table3[2014 Process Date])
And it worked like a charm! Thanks again!
If I'm reading your formula correctly, the target cells hold either the DATE, or a blank "".
If so, you can do a COUNTIF and do this:
=COUNT(B:B)
to get # of dates.
or
=COUNTA(B:B)-COUNT(B:B)
to get # of blanks.
(I used column B, not sure where your final values are in you're looking for - adjust accordingly)

Resources