Can I plot/filter just the peak value per day in excel - excel

I have a dataset which is amount (parts per million) against time (every minute)
I need to find the peak for each day, so that I can plot that against other data, I can manually do this using =MAX( but I have a lot of data points and I am sure there is a better way
Many Thanks for the help

I don't know where and how you want show this data, but, if you want get a max value amount per day, you can try add an array formula, like that:
=MAX(IF($COL_DATES = $DAY, $COL_VALUE, 0))
Replace $COL_DATES to your column of day date, replace $DAY to value of day what you want get max value and replace $COL_VALUE to your column of values.
After press CTRL + SHIFT + Enter

Related

Using Formula to determine Shift from Time data (Excel)

I have a column of time data formatted like this: Machine_Usage
I want to make an IF statement that returns 1, 2 or 3 corresponding to first, second or third shift if the times fall between certain values.
I already tried many times but not worked, please help me.
I want to find the right formula/syntax that can solved this problem for length of use of the machine based on the shift.
This is a possible approach, but not an answer because the question needs clarification on how to handle the following situations:
The interval [Start, End] is not within a single shift. According to some input data, it starts in one shift and ends in another one.
When End corresponds to a day after Start. This only can apply for shift 3, but based on the data there is no such scenario
In cell F2 put the following formula (the result is spilled, no need to drag down the formula)
=LET(start, C2:C20, end, D2:D20, lkup, H2:J4, shift, INDEX(lkup,,1),
lkStart, INDEX(lkup,,2), lkEnd, INDEX(lkup,,3),
MAP(start, end, LAMBDA(ss,ee, LET(startI, INT(ss) + lkStart,
endI, INT(ss) + lkEnd,
result, FILTER(shift, (ss >= startI) * (ee < endI), "Shift not found"),
IF(ROWS(result) > 1, "Overlap", result)
)))
)
Here is the output:
As you can see based on the data issue mentioned before no shift was found for any of the rows. Probably after data clean-up or more clarification, the formula should return a more realistic result.
Even the Shift information is represented in hh:mm format (see the previous screenshot). The end date of the last shift corresponds to the next day. Therefore the numeric values associated with the hours are the following:
Shift Start End
1 0.25 0.58
2 0.58 0.92
3 0.92 1.25
The logic of the formula is based on the above settings.

Excel: Calculate average time (duration), with criteria, between 2 columns

Breaking my head over this, time to look for help :(
I have a sheet with raw data, as illustrated below.
I'd like to calculate the average duration per TestName (column A) between the 2 timestamps (B and C) in another sheet.
How can I do this in 1 formula?
Note 1: The correct answer is (done manually)
test1 = 26:41:23
test2 = 08:23:10
Note 2: 1 formula please, without adding extra columns to calculate the duration per each first
Note 3: I cannot change the format of the raw data
Note 4: ignore empty fields
Thank you!
Use a new Column D to calculate the difference between start and end date on each row:
=DATEVALUE(C2)+TIMEVALUE(C2) - (DATEVALUE(B2)+TIMEVALUE(B2))
Next calculate the average on test1 and test2
=AVERAGEIFS($D:$D, $A:$A, "test1")
=AVERAGEIFS($D:$D, $A:$A, "test2")
Note that I'm using a comma as separator, in some languages, other separators, like semicolon are needed to write the formulas properly.
Now format the view to display at least the days in addition to the time: "DD - hh:mm:ss". Going beyond 31 days is a bit difficult as the month will count up.
If you don't like the formatting, go with the raw number format and extract the information through a bit of math. If it shows for example 1,5 it means one and a half days. I hope you can handle converting decimals to hours, minutes and seconds. MOD(ulo) and Rounddown are going to be your friends. :-)

Excel - averaging an n amount of rows based on condition in prior column

I have this table in excel:
Date value
1/2/1970 100.00
1/5/1970 99.99
1/6/1970 100.37
1/7/1970 100.74
1/8/1970 101.26
1/9/1970 100.74
1/12/1970 100.79
1/13/1970 101.27
1/14/1970 101.95
1/15/1970 101.97
1/16/1970 101.76
1/19/1970 102.21
1/20/1970 102.70
1/21/1970 102.00
1/22/1970 101.46
1/23/1970 101.49
1/26/1970 100.97
1/27/1970 101.45
1/28/1970 101.70
1/29/1970 102.08
1/30/1970 102.19
2/2/1970 102.02
2/3/1970 101.85
These are values that I have daily, and I need to construct a sheet that takes a monthly index of the daily values, example below:
date index
1/31/1970 some_index
2/28/1970 some_index
3/31/1970 some_index
4/30/1970 some_index
I could only get this far when it came to getting the index of 30 days:
=AVERAGE(INDEX(B:B,1+30*(ROW()-ROW($C$1))):INDEX(B:B,30*(ROW()-ROW($C$1)+1)))
I'm just not sure how to structure this in the most efficient, yet correct way possible. Not all months are the same amount of days, so I was hoping to check to get all the next n rows where the date starts with a "1" for example, sometimes certain days are also missing. I can't think of a catch all approach.
With 1/31/1970 in C1 try this,
=averageifs(daily!b:b, daily!a:a, "<="&c1, daily!a:a, ">="&eomonth(c1, -1)+1)
A PivotTable might be more convenient:

Hours Calculations in Excel 2010

I have an Excel 2010 workbook which contains a cell with the value of, say, 9876:54:32 (manually entered) representing 9876 hours, 54 minutes and 32 seconds of, say, phone talk time.
Then I have a cell with the value of, say, 1000 (manually entered) representing 1000 calls.
I want to divide the values to get the average talk time of 592.615 minutes per call.
I'm doing a regular =A1/B1 and it gives me an error.
* EDITED *
Thanks Brain Webster for correcting my math. I mean 9.876 hours. But the point is that Excel gives me an error, not my manual math. Playing around with it I discovered that Excel is fine with me with values up to 9999:59:59. Once I try with 10000:00:00 and up, it doesn't recognize it as a time value.
I love these seemingly easy riddles, so here is my solution as a formula and as a VBA attempt:
my original:
= (LINKS(A38;FINDEN(":";A38)-1)/24)+ZEITWERT("0"&RECHTS(A38;LĂ„NGE(A38)-FINDEN(":";A38)+1))
translated:
= (LEFT(A38,FIND(":",A38)-1)/24)+TIMEVALUE("0"&RIGHT(A38,LEN(A38)-FIND(":",A38)+1))
This will get you the right value to a given 10k text of a time duration. You would only have to setup the format of the cell to [h]:mm:ss. Then those values will look the same, but one would be a string and the other a number - and that is a major difference ;)
In vba it looks much more easier, and once defined, you can use it as a worksheetfunction.
Public Function GetDurationValue(ByVal strInput As String) As Double
Dim arrResult As Variant
arrResult = Split(strInput, ":") 'saves you parsing
GetDurationValue = (arrResult(0) / 24) + _
TimeSerial(0, arrResult(1), arrResult(2))
End Function
A38 = "10971:12:14"
=GetDurationValue(A38)
=457.13349537037
You can use LEFT and RIGHT function to retreive parts of the time value and then sum and multiply these values by 60 [minutes] (resp. 3600 [hours]).
Something like this for the hours, minutes, seconds (A1 is the cell with time value):
B1=VALUE(LEFT(A1;FIND(":";A1)))*3600
B2=VALUE(LEFT(A1;FIND(":";A1; FIND(":";A1))))*60
B3=VALUE(LEFT(A1;FIND(":";A1; FIND(":";A1; FIND(":";A1)))))
Now you can sum that:
C1=SUM(B1;B2;B3)
Then divede by calls count (A2 is the cell with the calls count):
D1=C1/A2
Finally format it like time:
E1=TEXT(D1/(24*3600);"d \day\s hh:mm:ss")
BTW: I tried that in Excel 2013 and when I enter 111:22:33 into a cell it automatically converts to a time. So then I can divide it like you try...
It appears that hours > 10000 are not recognised as such by Excel. Therefore we need to introduce an IF() to see whether this is the case and determined the alternative formula for the case where hours >10000
=IF(ISERROR(FIND(":",A2)),A2/B2, <SCRIPT IN CASE OF >10000>)
<SCRIPT IN CASE OF >10000> will now be:
VALUE(LEFT(A2,FIND(":",A2)))/24+VALUE(LEFT(A2,FIND(":",A2, FIND(":",A2))))/(24*60)+VALUE(LEFT(A2,FIND(":",A2, FIND(":",A2,FIND(":",A2)))))*(24*60*60)
combine and enjoy!
Assuming you don't exceed 100,000 hours in A1, and you always display hours, minutes and seconds then this formula should suffice
=IFERROR(A1/B1,(LEFT(A1)*10000/24+RIGHT(A1,10))/B1)
format result cell as [h]:mm:ss to get the result as a time value
With 10971:12:14 in A1 and 1000 in B1 that should give a result of 10:58:16 [or format result cell as [m]:ss to get minutes and seconds like 658:16]
This version will work with any number of hours and with or without seconds
=IFERROR(A1/B1,(LEFT(A1,FIND(":",A1)-1)/24+RIGHT(A1&IF(COUNTIF(A1,":*:"),"",":00"),5)/60)/B1)

How do I convert hh:mm:ss.000 to milliseconds in Excel?

I have a device which outputs the time in the format hh:mm:ss.000, e.g., 00:04:58.727 and I need to convert these to milliseconds.
I can't change the way the device outputs the times so I have to do it in Excel, but I don't know VB so am looking for a cell-by-cell solution.
Let's say that your time value is in cell A1 then in A2 you can put:
=A1*1000*60*60*24
or simply:
=A1*86400000
What I am doing is taking the decimal value of the time and multiply it by 1000 (milliseconds) and 60 (seconds) and 60 (minutes) and 24 (hours).
You will then need to format cell A2 as General for it to be in milliseconds format.
If your time is a text value then use:
=TIMEVALUE(A1)*86400000
UPDATE
Per #dandfra's comment this solution may not work in the Italian version of Excel.
Using some text manipulation we can separate each unit of time and then sum them together with their millisecond coefficients.
To show the formulas in the cells use CTRL + `
Use
=LEFT(B2, 2)*3600000 + MID(B2,4,2) * 60000 + MID(B2,7,2)*1000 + RIGHT(B2,3)
you can do it like this:
cell[B1]: 0:04:58.727
cell[B2]: =FIND(".";B1)
cell[B3]: =LEFT(B1;B2-7)
cell[B4]: =MID(B1;11-8;2)
cell[B5]: =RIGHT(B1;6)
cell[B6]: =B3*3600000+B4*60000+B5
maybe you have to multiply B5 also with 1000.
=FIND(".";B1) is only necessary because you might have inputs like '0:04:58.727' or '10:04:58.727' with different length.
Rather than doing string manipulation, you can use the HOUR, MINUTE, SECOND functions to break apart the time. You can then multiply by 60*60*1000, 60*1000, and 1000 respectively to get milliseconds.
Here it is as a single formula:
=(RIGHT(D2,3))+(MID(D2,7,2)*1000)+(MID(D2,4,2)*60000)+(LEFT(D2,2)*3600000)
try this:
=(RIGHT(E9;3))+(MID(E9;7;2)*1000)+(MID(E9;5;2)*3600000)+(LEFT(E9;2)*216000000)
Maybe you need to change semi-colon by coma...

Resources