I cannot get too specific due to my company regulations, so I will attempt to provide as much info as I can.
I have a for loop that goes through a list of names. In the loop, I have another loop that determines if a certain value should be assigned to to another list using the Name. Here is an Example
John Doe is number one on my list.
Jane Doe is number two.
John Doe
17:20 = 1
17:25 = 2
17:40 = 1
17:45 = 0
19:00 = 1
19:10 = 0
19:30 = 1
19:50 = 0
The Values are assigned based off of something that occurs during those times.
If X happens, Add 1 to the value.
If Z happens, subtract 1 from the value.
This will repeat for Jane Doe once the last row for John Doe is hit
(Everything above this I have already programed)
Where I am stuck, is I need to be able to have excel Subtract the time with the value of 0, from the time with the value of 1
For Example
17:00 = 1
17:10 = 2
17:20 = 3
17:30 = 4
17:35 = 3
17:40 = 2
17:50 = 1
18:00 = 0
I need excel to be able to subtract 17:00 from 18:00 based off of the value on the right.
I.e
If Range(B & [Whatever row]).Value = to 0 And Range(A & [Whatever row]).Value = 1 then
subtract Range(A & [Whatever row]) from Range(A & [Whatever row])
But the problem is when I doe this, it will subtract 17:50 from 18:00 due to it falling in the same circumstance.
I fixed this through having ten different If else if circumstances, but I do not want to keep it that messy.
Does anyone have any other options?
I am fairly new to coding, so I am not too sure if there is anything else I can do other than that
Related
I have a data as below. I have created column "difference in values" manually, the calculation is value at 8:15 AM - value at 8:00 AM which is 2 in second row and so on for all values of column Tushar and Lohit respectively. How can i do this calculation in Spotfire i believe over and previous function can help but i am unable find anything on this. Please help
Name Time Values Difference in values
Tushar 08:00 AM 2 0
Tushar 08:15 AM 4 2
Tushar 08:30 AM 5 1
Tushar 08:45 AM 6 1
Tushar 09:00 AM 7 1
Lohit 08:00 AM 2 0
Lohit 08:15 AM 4 2
Lohit 08:30 AM 5 1
Lohit 08:45 AM 6 1
This should work
SN([Values] - Max([Values]) over (Intersect(Previous([Time]),[Name])),0)
where Max(..) is just to have an aggregation, since it is only looking at the previous Time row for each value of Name. [so Min would work just as well].
SN(...) is there to set the result to 0 when it is empty (as in the first row of each Name).
Hello I have to count how many people were scheduled on each hour in excel so I transformed starting and ending data/time to only contain time and basing on it I tried to substract these two information but I only get an hour then but what I need is the hours to be like this:
instead
starting on 9:00
ending on 17:00
this
9:00
10:00
11:00
12:00
13:00
14:00
15:00
16:00
17:00
to count every hour that employee was at work. But I don't know how :(
Or is there a better way of doing that?
Assuming your table looks something like this:
Person
Start
End
09:00
10:00
11:00
12:00
13:00
14:00
15:00
Alice
08:35
16:35
1
1
1
1
1
1
1
Bob
09:35
17:35
0
1
1
1
1
1
1
Carl
10:35
18:35
0
0
1
1
1
1
1
Dan
11:35
19:35
0
0
0
1
1
1
1
Ed
12:35
20:35
0
0
0
0
1
1
1
Total present
1
2
3
4
5
5
5
You can compute the entries 0 or 1 in each cell under the times using the formula
=IF(AND((E$4>$C6);(E$4<=$D6));1;0)
In the formula, E$4 is a reference to the column header, e.g. "9:00", $C6 and $D6 are references to the start and end times of the person. They are defined using partial absolute references ($) so the same formula can be copied and pasted in all the cells.
The result will be 1 if the person was present at that time and 0 if not.
The "Total present" formulas just sum up the 1's and 0's in the column.
I have the following Excel spreadsheet
A B C D
1 Product ID Time of Event
2 27152 01.04.2017 08:45:00 27152 70 Min.
3 27152 01.04.2017 09:00:00 29297 108 Min.
4 27152 01.04.2017 09:55:00 28802 28 Min.
5 29297 02.04.2017 11:02:00
6 29297 02.04.2017 12:50:00
7 28802 18.04.2017 11:48:00
8 28802 18.04.2017 12:00:00
9 28802 18.04.2017 12:13:00
10 28802 18.04.2017 12:16:00
In Column A you can find different Product IDs.
In Column B the time when an event happens in the Product ID.
Each event is listed in the table; therefore, a ProductID can appear
several times in Column A.
In Column D I want to show now the difference in minutes between
the first and the last event which happens in a product ID.
D2 = 9:55:00 - 8:45:00 = 70 Min.
D3 = 12:50:00 - 11:02:00 = 108 Min.
D4 = 12:16:00 - 11:48:00 = 28 Min.
Therefore, I would need something like a DIFFERENCE-IF-Formula.
One of my ideas so far was going by the LARGE and SMALL function.
=LARGE(B2:B4;1)-SMALL(B2:B4;1)
However, this way I would have to find each array (B2:B4, B5:B6, B7:B10) seperatly; therefore, I would prefer to have the productID as a criteria in the formula.
Summarized:
Do you have any idea how I could calculate the difference in minutes between the last and the first event of a certain ProdcutID in the list?
I would prefer to avoid any kind of array formula.
=ROUND(MMULT(AGGREGATE({14,15},6,B$2:B$10/(A$2:A$10=C2),1),{1;-1})*1440,1)&" Min"
and copied down.
I've a feeling the separators for horizontal and vertical arrays in German versions of Excel are the period (.) and semicolon (;) respectively, so I believe you'll need:
=RUNDEN(MMULT(AGGREGAT({14.15};6;B$2:B$10/(A$2:A$10=C2);1);{1;-1})*1440;1)&" Min"
though please let me know if that doesn't give the required results.
Regards
With some conditions,
1. assuming that you convert column B into 2 columns
2. times is in ascending order
A B C
Product ID Time of Event TIMES
27152 01.04.2017 8:45:00
27152 01.04.2017 9:00:00
27152 01.04.2017 9:55:00
29297 02.04.2017 11:02:00
29297 02.04.2017 12:50:00
28802 18.04.2017 11:48:00
28802 18.04.2017 12:00:00
28802 18.04.2017 12:13:00
28802 18.04.2017 12:16:00
This will work without using array
=(INDEX($C$2:$C$10,SUMPRODUCT(MAX(ROW($A$2:$A$10)*(D2=$A$2:$A$10))-1))-INDEX($C$2:$C$10,MATCH(D2,$A$2:$A$10,0)))*1440
Convert time into minutes
=(time*1440)
Look for first matching value
=INDEX($C$2:$C$10,MATCH(D2,$A$2:$A$10,0))
Look for last matching value
=INDEX($C$2:$C$10,SUMPRODUCT(MAX(ROW($A$2:$A$10)*(D2=$A$2:$A$10))-1)
NOTE If last value is SMALLER then first value, you will receive an error.
I am working on a scheduling sheet. I want to calculate the distance in weeks since a person was last scheduled on one of 3 different 'jobs'. I only want to look at the time since someone was last scheduled on a weekend, and individuals may be scheduled on weekdays intervening between the last weekends.
For example:
Date Day_of_week Task_a Task_b Task_c Distance_a Distance_b Distance_c
7/1/2015 Wednesday Ed Mary Amy 0 0 0
7/2/2015 Thursday Bill Judy Bob 0 0 0
7/3/2015 Friday Ed Mary Amy 0 0 0
7/4/2015 Saturday Ed Mary Amy 0 0 0
7/5/2015 Sunday Ed Mary Amy 0 0 0
7/6/2015 Monday Bill Mary Bob 0 0 0
7/7/2015 Tuesday Ed Judy Amy 0 0 0
7/8/2015 Wednesday Ed Amy Bob 0 0 0
7/9/2015 Thursday Bob Ed Judy 0 0 0
7/10/2015 Friday Ed Bob Judy 0 0 0
7/11/2015 Saturday Ed Bob Judy 7 0 0
7/12/2015 Sunday Ed Bob Amy 7 0 7
gives the correct distances for each of the 3 tasks with labels for cells first followed by new line of data at each date.
For Distance A I have attempted:
{=IF(AND(B3="Saturday", (A3-MAX(IF($C$2:E2=C3, $A$2:A2, 0)))/7 <53), (A3-MAX(IF($C$2:E2=C3, $A$2:A2, 0)))/7, ".")}
which returns a value on each Saturday (as intended), but cannot scan past the most recent weekday assignment, giving falsely low values. I have attempted other IF(OR) & IF(AND) statements but the first failure generates a false value effectively ceasing the program.
Any assistance with code and formatting the example to .csv or tab seperated values would be appreciated.
OK so just to recap you need to calculate the distance in weeks from the current date to date of the previous job scheduled at the weekend.
The conditions are:-
Current date must fall on a weekend
Previous date must also be on a weekend
Previous date must not be on same weekend as current date
Must be same person.
I've found it easier to use the WEEKDAY function to check if the dates fall on a weekend, so putting this all together I get:-
=IF(WEEKDAY($A3,16)>=3,"",
IF(MAX($A$2:$A2*(C$2:C2=C3)*(WEEKDAY($A$2:$A2,16)<3)*(($A3-$A$2:$A2)>1))=0,"",
INT(($A3-MAX($A$2:$A2*(C$2:C2=C3)*(WEEKDAY($A$2:$A2,16)<3)*(($A3-$A$2:$A2)>1))+1)/7)
)
)
to be entered as an array formula in row 3 using Ctrl Shift Enter
I think the general logic of your formula is OK, but OR and AND functions don't work very well in array formulas so I have replaced ANDs with multiplications.
At the moment this only checks for a person appearing in the same column so I will post another version if it needs to check across the three columns.
Is it possible to count or countif by using a column as the data, a cell for the criteria (or what to match) and range of what to count?
Here is what I am looking at:
A1 B C D E F G H I J K L M N O
2 Running Data Total Count of Tardies (by category)
3 Date Employees Leader Start of Shift Break 1 Lunch Break 2 Employees Start of Shift Break 1 Lunch Break 2 Total
4 1-Jul Abe Sue 15 Abe 0
5 3-Jul Steve Bob 20 Anna 0
6 5-Jul Eve Andy 9 20 Eve 0
7 7-Jul Anna Andy 30 Helen 0
8 15-Jul Abe Sue 15 Mark 0
9 18-Jul Anna Andy 10 Steve 0
10 20-Jul Helen Sue 9 0
11 31-Jul Mark Bob 45 0
I am trying to count the data entered on the left (running data) in each category and having it show based on the Employees on the right (in the orange cells). So Abe should show 1 for Start of Shift, Eve should show 1 for Break 1 and Break 2, and Anna should show 2 for Start of Shift.
I have tried using:
=countif(C:C,$J4,D:D) to get the data from JUST Column D for Start of shift, but it gives and error saying too many arguments for the function have been entered.
Help...
...and Thanks!
Countif will only look at 1 column to decide what to count.
Countifs will look at multiple columns. Your formula would look something like this:
=COUNTIFS($C:$C,$J4,E:E,">0")