I have been collecting data over the past few data from an energy metering project i have set up.
The values that are recorded are saved in a CSV file and then extracted through usb drive.
i have opened and assessed the CSV file in excel and the data hasnt been recorded how i would like.
Instead of logging once every minute it has logged every 7 seconds.
This has created a problem as the template csv file i have created to average these figures wont work now.
i am trying to create a VBA marco to assess all the data and where the second value is higher then 6 seconds, i want it to delete it for example:
here is some of the values i am working with:
16:29:05 PAC3 239.8030701 50.01350021 1073.719116 4.450771332 0
16:29:05 PAC2 239.2398834 50.01499939 3046.500732 12.62684536 0
Above is how i would like it to look.
but it currently looks like below where there are several entries under the 16:30 time
16:30:02 PAC3 239.6912689 50.06306076 1092.592651 4.229027748 0
16:30:02 PAC2 238.8809052 50.06230927 3535.760254 14.82234478 0
16:30:09 PAC3 239.8191681 50.07057571 999.7850342 4.125905514 0
16:30:09 PAC2 239.2037506 50.06982422 2644.371338 11.05446911 0
because it is logging every 7 seconds i am getting about 7 - 8 logs per minute per PAC
so where the second value is greater than 6 seconds i would like the whole row to be removed. and continue to cycle through the entire column and remove them. These cells are formatted into a time format but do contain a time and data value
I have searched for ways to complete this task but have found no solutions
any help appreciated.
If you use =SECOND() function you can extract the seconds from the time value. Then loop up the column starting at the bottom and delete the rows that contain the values you don't want.
Related
I'm setting up a database containing information of production runs. Each production run usually takes place within 24 h, leading to about 7 runs/week. Multiple values and variables are entered into the database, giving an idea how well/poorly each run went. I want to visualize this information in graphs, which give a weekly view (so 7 runs in 1 graph). My idea was to have a 2nd worksheet where I can input a week number, having Excel then show all runs (and all their relevant info) that took place in that week. This set area could then be used to fetch info for the graphs from. Idea being, I input a different week number, the values in this area change based on the runs for the new week and the graph looking at this are will automatically update.
I've been working with HLOOKUP based on dates, which works fine if 1 run takes place on 1 day.
Example: =HLOOKUP(D$2,'Run Values'!$C$6:$XFD$54,3,TRUE), where D$2is the date on which the run took place, 'Run Values!$C$6:$XFD$54 is the range where the values for each run can be stored (2nd worksheet), & 3 is the row for this particular piece of info (this value changes per row that I use the HLOOKUP in, depending on what I'm looking for).
However, when for some reason multiple runs took place on the same date (which occasionally happens), it only retrieves the first run encountered for that run. This is probably because I'm checking per date.
Is there a way to either improve this code (using HLOOKUP) to get it to do what I want it to do? Or is there an alternative (maybe more easy) way to get to where I want to be?
Sample data consists of weeks placed next to each other (1 week of data here):
43
43
43
43
43
25/10/2021
26/10/2021
26/10/2021
27/10/2021
28/10/2021
659
660
660
661
662
879
880PUR
881
882
883
34157
23034
27224
41740
40062
29.06%
29.75%
28.29%
27.51%
26.57%
12.58
9.65
9.65
14.20
16.17
I'm looking to extract the 1st through 4th row of the green values, 2nd through 9th row of the blue values, all of the light orange and all of the dark orange values for an entire week, and all this for 1 week of data at a time. So if I would request week 43 on my second worksheet, then it would retrieve them from this data base as such:
Any help would be much appreciated.
In assessing how many agents can be added to certain times of day without exceeding the number of seats in the call center, I'm trying to discern how many agents are scheduled for each half hour interval on each day of the week.
Using the =SUMPRODUCT(((A$2:A$1000<=D2)+(B$2:B$1000>D2)+(A$2:A$1000>B$2:B$1000)=2)+0) formula I've been able to identify how many total agents work for each interval, however this doesn't take the day of week into account.
I currently have my spreadsheet setup this way:
K is the start time of the shift, L is the end time of the shift, M to S pulls data from another sheet that shows a 1 if the agent works on that day of the week and 0 if they do not, and then U has all the time intervals listed out. In the example, it's cut off but the columns continue down as needed. U goes to 49 and I've just been using a range from 2 to 500 for the others as we currently do not have that many shifts and I'm leaving space for the moment.
After some Googling, I tried =SUMPRODUCT(--(M2:M500="1"),(((K$2:K$1000<=U2)+(L$2:L$1000>U2)+(K$2:K$1000>L$2:L$1000)=2)+0)) but it only returns #VALUE! so I'm not sure what I'm doing wrong.
Any suggestions of how I can make this work? Please let me know if more information would be useful. Thanks.
=sumproduct(($K$2:$K$1000<=U2)*($L$2:$L$1000>=U2))
That will count the number of occurrences where the start time is less than or equal to the time in U2 AND the end time is greater than or equal to U2. It will check time from row 2 to row 1000. Any time one condition is checked and its true the comparison will result in value of TRUE and FALSE when its not true. The * act like an AND condition while at the same time converts TRUE and FALSE values to 1 and 0. So both conditions have to be true for a value of 1 to result. Sumproduct then totals up all the 1 and 0 to get you a count.
In order to consider the days of the week, you will need one thing to be true. Your headers in M1:S1 will need to be unique (which I believe they are). You will need to either repeat them in adjacent columns to M or in say V1 you have a cell that can change to the header of the day of the week you are interested in. I would assume the former so you can see each day at the same time.
In order to do this you want to add more conditions and pay attention to you reference locks $.
In V2 you could use the following formula and copy down and to the right as needed:
=sumproduct(($K$2:$K$1000<=$U2)*($L$2:$L$1000>=$U2)*(M$2:M$1000))
UPDATE #1
ISSUE 1 Time ranges ending the following day (after midnight)
It is based on the assumption that the ending time is later than the start time. When a shift starts at 22:00 and end at 6:30 as an example, our mind says that the 0630 is later than 22:00 because it is the following day. Excel however has no clue that 0630 is the following day and without extra information assumes it to be the same day. In excel date is stored as an integer and time is stored as a decimal. When you only supply the time during entry it uses 0 for the date.
In excel the date is the number of days since 1900/01/00. So one way to deal with your time out is to add a day to it. This way excel will know your out time is after your in time when the hour is actually earlier in the day.
See your sample data below.
Using your sample data, I did a straight copy of the value in L and placed it in M (=L3 and copy down). I then changed the cell display format from time to general. This allows you to see how excel sees the time. Note how all the time is less than 1.
In column N I added 1 to the value when the out time was less than the in time to indicate that it was the following day and we had not actually invented time travel. I also used the trick of a math operation will convert a TRUE/FALSE result to 1 or 0 to shorten the equation. I used =M3+(L3<K3) and copied down. You will notice in the green bands that the values are now greater than 1.
In the next column I just copied the values from N over using =N3 copied down, and then I applied just a time display format for the cell. Because it is only time format, the date is ignored and visually your time in column O looks the same as column L. The big difference is excel now knows that it is the following day.
you can quickly fix your out times by using the following formula in a blank column and then copying the results and pasting them back over the source column using paste special values.
=M2+(L2<K2)
The next part is for your time check. When looking at the 12:00 time you need to look at 1200 of the current day incase a shift started at 12:00 and you need to look at the 1200 period of the following day. In order to do that we need to modify the the original formula as follows:
=sumproduct(($K$2:$K$1000<=$U2)*($L$2:$L$1000>=$U2)*(M$2:M$1000)+($K$2:$K$1000<=$U2+1)*($L$2:$L$1000>=$U2+1)*(M$2:M$1000))
Note that the + in the middle of (M$2:M$1000) + ($K$2:$K$1000<=$U2+1)? This + acts like an OR function.
Issue 2 Time In/Out 15 minute increments, range 30 minute increments
You may be able to achieve this with the ROUNDDOWN Function or MROUND. I would combine this with the TIME function. Basically you want to have any quarter hour start time be treated as 15 minutes sooner.
=ROUNDDOWN(E3/TIME(0,30,0),0)*TIME(0,30,0)
Where E3 is your time to be converted
So your formula may wind up looking something like:
=sumproduct((ROUNDDOWN($K$2:$K$1000/TIME(0,30,0),0)*TIME(0,30,0)<=$U2)*($L$2:$L$1000>=$U2)*(M$2:M$1000)+((ROUNDDOWN($K$2:$K$1000/TIME(0,30,0),0)*TIME(0,30,0)<=$U2+1)*($L$2:$L$1000>=$U2+1)*(M$2:M$1000))
similar option could be used for the leaving time and rounding it up to the next 30 minute interval. In which case just use the ROUNDUP function. Though I am not sure it is required.
This question already has answers here:
1 microsoft second = 0.00001157407407
(3 answers)
Closed 4 years ago.
I have a column of time values in excel that are from exporting from another piece of software. The time is formatted as hh:mm:ss.sss (e.g. 00:00:02.147 -> 0 hrs, 0 min, 2 s and 0.147 ms).
I want to change this into total number of seconds in excel however any function performed on the cells results in a #VALUE! error. I have tried changing the cell type from General to Text to Time to Custom (i.e. [ss]) etc. however nothing has worked. Is there anyway I can do this? This also causes issues for plotting in python.
The custom format of "hh:mm:ss.000" should do what you are after.
You can then narrow that down to "ss.000" and just use =A1 or even just nab the seconds with =SECOND(A1) (if you wanted to do this long-hand then you can do a =RIGHT(A1,6) with a format of "ss.000" or even =TEXT(A1,"ss.000") / =TEXT(RIGHT(A1,6),"ss.000").
The issue being that using "ss.sss", excel is trying to append seconds on to time again rather than milliseconds, so if excel can first know the milliseconds exist you should be able to extract the seconds.
EDIT
If it's the total number of seconds you are after, multiply the DateTime value by the number of seconds in a day: =A1*86400
My current data is like so:
I use the MIN formula to get the minimum of these times. I am measuring a process time, so the time on T is the least, and T+1 is actually greater. How can I alter my MIN formula to account the 11:51 as the min time?
I can use MAX for above problem, but then when times are 3, 4 , 5 AM, it will give me 5 AM when I want MIN throughout.
One way around this is to add the date to the time. You do not need to display it, but you do need the date as part of the time. JNevill is all over this without coming right out and saying it. You can either do as Jnevil suggest and offsetting all your time by an equal amount so it is all in the same day or you have to add +1 to the time when it crosses the midnight threshold. Adding +1 to your time will tell excel that it is on the following day.
In Excel time is stored as a decimal and days are stored as integers. So any time with no date attached will go from 0.xxx to 1.xxx when +1 is added. The cell will still display xxx as time and the 1 does not enter in to the display. However the 1 will be very important in determining MIN or MAX because of that integer of 0 or 1 out front.
You will probably need to do this through a helper column. Without seeing a column of data it is hard to say if you only need to add 1 or if you will need to add 2 or more depending on how many days the data covers
In an Excel 2003 spreadsheet, I have the top row of cells calculating the number of days and hours I have worked on something based on data I put in the cells below for each category. For example I enter the time spent on Programming, Spoken languages, house, piano, guitar...etc. The top cell in each category will keep track of and display how many days and hours I spent as I add the time spent for each category each day. I want to evaluate this top row and then list in a "report" (like a pop up box or another tab or something) in order from least amount of time to the most amount of time. This is so I can see at a glance which category is falling behind and what I need to work on. Can this be done in Excel? VBA? Or do I have to write a program from scratch in C# or Java? Thanks!
VH
Unbelievable... I've been scolded for trying to understand an answer and requested to mark this question answered. I don't see anything to do this and could not find anything that tells you how, so I'm just writing it here. MY QUESTION WAS ANSWERED... But thanks anyway...
Consider the following screenshot:
The chart data is built with formulas in columns H3:I3 and below. The formulas are
H3 =INDEX($B$3:$F$3,MATCH(SMALL($B$2:$F$2,ROW(A1)),$B$2:$F$2,0))
I3 =INDEX($B$2:$F$2,MATCH(SMALL($B$2:$F$2,ROW(A1)),$B$2:$F$2,0))
Copy down and build a horizontal bar chart from the data. If you want to change the order of the source data, use LARGE() instead of SMALL().
Alternative Approach
Instead of recording your data in a matrix, consider recording in a flat table with columns for date, category and time spent. That data can then easily be evaluated in many possible ways without using any formulas at all. The screenshot below shows a pivot table and chart where the data is sorted by time spent.
Edit after inspecting file:
Swap rows 2 and 3. Then you can choose one of the approaches outlined above.
Consider entering the study time as time values. It is not immediately clear if your entry 2.23 means 2 hrs and 23 minutes, or 2 hrs plus 0.23 of an hour, which totals to 2hrs, 13 minutes.
If you are using the first method, then all your sums involving decimals are off. For example, the total for column B is 7.73 as you sum it. Is that meant to be 7 hrs and 73 minutes? That would really be 8 hrs and 13 minutes, no? Or is it meant to be 7 hrs and 43 minutes? You can see how this is confusing. Use the colon to separate hrs and minutes and - hey - you can see human readable time values and don't have to convert minute values into decimals.