Formula to Repeat and increment Numbers and reset when ID changes - excel

I am looking for a start in the right direction and I hope someone on this forum has run into this issue. I have an excel table with 24K jobs on it and a technician assigned to every job. These technicians have 40 weeks to complete all the jobs assigned. I have a helper table with each technician’s id and how many jobs per week then need to complete all the work. I have sorted the jobs by geographic area for efficiency. I need a formula that will look at the Technician id and if they are receiving 3 jobs per week that it will number the first 3 with a 1, and the next 3 with a 2 and so on. And when it switches Technician it would reset the counter.
In the example below Tech 1 is assigned 3 jobs per week, and Tech 2 has 2 jobs per week.
| JobID | Tech | Grouping |
|-------|--------|----------|
| BK025 | Tech 1 | 1 |
| CD044 | Tech 1 | 1 |
| DE024 | Tech 1 | 1 |
| DE031 | Tech 1 | 2 |
| DE035 | Tech 1 | 2 |
| FT083 | Tech 1 | 2 |
| IR004 | Tech 2 | 1 |
| IR006 | Tech 2 | 1 |
| IR052 | Tech 2 | 2 |
| IR061 | Tech 2 | 2 |
| IR062 | Tech 2 | 3 |
| IR072 | Tech 2 | 3 |
I have been searching SO and Google looking for an answer but may not be using the correct key words.I have found this formula =ROUNDUP((ROW()-offset)/repeat,0) -- Found on exceljet -- which will work, but in order to get it to work properly I would have to filter to each tech individually.

Assuming your helper table is something like in the screenshot below, you could use an approach like the following:
=ROUNDUP(COUNTIF(B$2:B2,B2)/VLOOKUP(B2,$E$1:$F$3,2,0),0)

Related

Grouping a list of items in to as equal in numbers as possible

Requirement: Split a list in to 4 separate groups, based on a value for each row.
| Player | Skill |
| ------------- |:-------------:|
| Player 1 | 10000 |
| Player 2 | 50000 |
| Player 3 | 2000 |
| Player 4 | 11000 |
| Player 5 | 7525 |
| Player 6 | 100 |
| Player 7 | 999 |
| Player 8 | 14579 |
| Player 9 | 26700 |
So in the example above, these players would be split in to 4 groups:
| Group | # of players |
| ------------- |:-------------:|
| Group1 | 2 |
| Group2 | 2 |
| Group3 | 2 |
| Group4 | 3 |
The number of players in a group needs to be as close as possible, however, as a group, the groups total Skill needs to around similar in numbers each time.
Before I go too far down the rabbit hole (as wording a question like this in a simple google search is not turning out very well) are there any built in functions of Excel that can be leveraged to achieve this or possible efforts in VBA that can be explored to achieve the required result?
This isn't an answer! But suppose you try a simple algorithm:
Calculate average skill level (ASL) for all 9 players
Set TSG (total skill for group) to zero.
Loop:Take largest skill Level (LSL) of remaining players
If TSG+LSL>ASL
Go to next group
Else
Add to total skill (TSG) for this group
Remove player from list
Repeat loop until no players remaining.
If you apply this by hand to your data you should get:
Average=30725.75
+---------+---------+---------+---------+
| Group 1 | Group 2 | Group 3 | Group 4 |
+---------+---------+---------+---------+
| 50000 | 26700 | 14579 | 10000 |
| | 2000 | 11000 | 7525 |
| | 999 | | |
| | 100 | | |
| | | | |
| 50000 | 29799 | 25579 | 17525 |
+---------+---------+---------+---------+
Clearly there are a couple of issues - you might not want a single group containing only player with highest skill level. Also you might want to re-average the remaining players after taking out the most skilful player. Should be a starting point though - could be implemented fairly easily with formulas or VBA.

Generate a master table based on a unique identifier with columns for the data from each table/worksheet

I am currently working in Excel but I am willing to consider solutions in (free) database software. The data I have is organized by time period, one worksheet for each period. The worksheets all have the same column structure.
Here is an example of the data from the 2017-Q1 worksheet:
| Time Period | Product ID | Prod. Category ID | Product Scale |
| 2017 - Q1 | 0012345678 | 012345 | 3 |
| 2017 - Q1 | 0023456789 | 012345 | 1 |
| 2017 - Q1 | 0033333588 | 022235 | 3 |
| 2017 - Q1 | 0123333333 | 022235 | 1 |
Here is an example of the data from the 2017-Q2 worksheet:
| Time Period | Product ID | Prod. Category ID | Product Scale |
| 2017 - Q2 | 0012345678 | 012345 | 5 |
| 2017 - Q2 | 0033333588 | 022235 | 7 |
| 2017 - Q2 | 0123333333 | 025444 | 5 |
| 2017 - Q2 | 0145555578 | 025444 | 1 |
The things that I am particularly focused on are:
Product ID 0023456789 does not appear in 2017-Q2, so the corresponding column in the master worksheet should show something (it could be blank, it could be NULL, it could be N/A, it doesn't matter as long as it is always the same.) The same thing needs to happen when a Product ID first appears in a later time period, the time periods before that should have the same N/A (or NULL, or blank, or whatever) This means that in order to form the master worksheet, I need to make a consolidated list of all of the Product IDs from all of the time periods, since not all of the Product IDs are present in every time period.
Product ID 0123333333 changed Prod. Category ID, so I need to always pull at least the Prod. Category ID column and the Product Scale column for each time period, just to be sure if it has changed or not.
I want to generate a master worksheet as follows (abbreviating column names just for space constraints here in this website):
| Product ID | 2017-Q1PCID | 2017-Q1 PS | 2017-Q2 PCID | 2017-Q2 PS |
| 0012345678 | 012345 | 3 | 012345 | 5 |
| 0023456789 | 012345 | 1 | N/A | N/A |
| 0033333588 | 022235 | 3 | 022235 | 7 |
| 0123333333 | 022235 | 1 | 025444 | 5 |
| 0145555578 | N/A | N/A | 025444 | 1 |
I have 12 different time period worksheets, so the master worksheet would need to first make a master list of unique Product IDs and then have 24 additional columns, because there are 2 columns for each time period (one column for the Product Category ID and another for the Product Scale ID, for that time period.) Furthermore, I should mention that each time period worksheet has 8,000-12,000 Product ID records, so ideally the solution should be able to handle thousands of rows fairly quickly.
TLDR : use index() match() .
Assuming the table 1 is located at "Sheet1" and the "Product ID" in the last table is located in cell A1, put this in B2 :
=IFERROR(INDEX('2017-Q1'!C:C,MATCH(A2,'2017-Q1'!B:B,0)),"")
and in C2 :
=IFERROR(INDEX('2017-Q1'!D:D,MATCH(A2,'2017-Q1'!B:B,0)),"")
and drag downwards.
Idea : 'load' the answer if the Product ID is matched in the source sheet, and put blank if no Product ID match is found.
Hope it helps. (:

Node.js : Check entries regularly based on their timestamps

I have a Node.js backend and MSSQL as database. I do some data processing and store logs in a database table which shows which entity is a what stage in the progress, e.g. (there are three stages each entity has to pass)
+----+-----------+-------+------------------------+
| id | entity_id | stage | timestamp |
+----+-----------+-------+------------------------+
| 1 | 1 | 1 | 2019-01-01 12:12:01 |
| 2 | 1 | 2 | 2019-01-01 12:12:10 |
| 3 | 1 | 3 | 2019-01-01 12:12:15 |
| 4 | 2 | 1 | 2019-01-01 12:14:01 |
| 5 | 2 | 2 | 2019-01-01 12:14:10 <--|
| 6 | 3 | 1 | 2019-01-01 12:24:01 |
+----+-----------+-------+------------------------+
As you can see in line with the arrow, the entity no. 2 did not go to stage 3. After a certain amount of time (maybe 120 seconds), these entity should be considered as faulty and this will be reported somehow.
What would be a good approach in Node.js to check the table for those outtimed entities? Some kind of cron job which checks all lines every x seconds? That sounds rather clumsy to me.
I am looking forward to our ideas!

Using IF AND to calculate based on one or more criteria

Within a resource planner, my data has a row for each employee, and columns detailing the team they work for. Another column details the available days they will work in the year. The teams are also displayed along a row at the top, see below :
A | B | C | D | E | F | G |
1 Employee | Team 1 | Team 2 | Days | Finance | Risk | IT |
2 Employee 1 | Finance | | 170 | | | |
3 Employee 2 | Risk | Finance | 170 | | | |
4 Employee 3 | Finance | | 170 | | | |
5 Employee 4 | IT | Risk | 170 | | | |
6 Employee 5 | IT | Finance | 170 | | | |
I want to use columns E:G as a supply calculator per team. Therefore, the formula in cell E2 would be "=IF(B2=E1,D2,0)" and copied along the row, returning the 170 days under Finance and 0 under the rest.
The issue lies where an employee divides his time between two different teams. As you can see, some employees can work for 2 different teams (Employee 2 works for both Finance and Risk, for example). The formula in E3 would therefore need to be some kind of IF AND, where if a value is present in the Team 2 column (C), the value in the Days column (D) would be divided by two and split across the relevent team columns.
I've tried a few options, IF AND, nested IFS etc but cant seem to get the syntax correct. Any help greatly appreciated.
=IF(ISNUMBER(MATCH(E$1,$B2:$C2,0)),$D2/COUNTA($B2:$C2),0)
You actually want OR and COUNTA:
=IF(OR($B2=E$1,$C2=E$1),$D2/COUNTA($B2:$C2),0)

Show top 3 from list based on difference

I have 2 lists;
"yesterday" and "today".
As rows I have a list of companies and the data shown is customer satisfaction going from 0-10. I want to show the top 3 companies that has the best difference between "yesterday" and "today".
How would you approach this??
Expected output looking for top 1:
Yesterday - Today
Company A: 5 10
Company B: 7 8
Company C: 8 6
Top 1: Company A (Since they moved the most(5 positive points))
Assuming your data is like this:
#########Sheet1<YESTERDAY>########
| A | B |
1|Companies| Customer satisfaction|
2|Company1 | 6
3|Company2 | 3
4|Company3 | 4
5|Company4 | 1
6|Company5 | 9
###########Sheet2<TODAY>##########
| A | B | C | D |
1|Companies| Customer satisfaction|Absolute changes | RANK |
2|Company1 | 1 | | |
3|Company2 | 7 | | |
4|Company3 | 7 | | |
5|Company4 | 4 | | |
6|Company5 | 8 | | |
Put this formula into Cell C2to get absolute change:
=ABS(VLOOKUP(A2,YESTERDAY!$A$2:$B$6,2,FALSE)-B2)
Put this formula into Cell D2to get Rank:
=RANK(C2,$C$2:$C$6,0)
So, 1,2,3 in Column RANK are best changes.
I assume best difference as highest difference.run a loop and take the first row company from yesterday as well as the customer satisfaction value and search that same company in today in another inner loop and find the difference of the two values and save it in an array.After that sort the array and display the top 3.

Resources