Dear All,
I am struggling with an app that I have been creating to replicate our roster system at work.
- I have a fixed set of employees (e.g. 5) belonging to one shift (Shift A) which is saved to collection1. See Table below
| Shift Name | Employee Number | Employee Name |
| SHIFT A | 1 | ABC1 |
| SHIFT A | 2 | ABC2 |
| SHIFT A | 3 | ABC3 |
| SHIFT A | 4 | ABC4 |
| SHIFT A | 5 | ABC5 |
- I have another collection (collection 2) that lists down the shift schedule details over a predetermined time period. E.g. over 35 days, a person belonging to shift A will work 7 times in the morning, 7 times in the afternoon etc. See Table 2
| ShiftName | ShiftType | StartTime | EndTime | StartDate | IncrementDate |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date2 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date3 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date4 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date5 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date6 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date7 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date1 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date3 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date4 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date5 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date6 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date7 |
- I need to merge both collections so that I can create a new collection that lists down each shift for each person. See Table 3
| ShiftName | ShiftType | StartTime | EndTime | StartDate | IncrementDate | EmpName |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date1 | ABC1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date2 | ABC1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date3 | ABC1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date4 | ABC1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date5 | ABC1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date6 | ABC1 |
| SHIFT A | Morning | 06:00 | 13:00 | Date1 | Date7 | ABC1 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date1 | ABC2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date2 | ABC2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date3 | ABC2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date4 | ABC2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date5 | ABC2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date6 | ABC2 |
| SHIFT A | Afternoon | 13:00 | 20:00 | Date2 | Date7 | ABC2 |
etc. for all employees.
I have followed all forums on how to merge one collection with one another using the lookup function to search for SHIFT A since it is the common field however I cannot get anything to work and I am struggling with it. Any help would be greatly appreciated.
Thanks,
Alistair

Report
All responses (
Answers (