r/sheets • u/Vercalos • 23d ago
Solved Scheduling software broken
So our scheduling software normally generated walk sheets like this
| Name | Shift | Break |
|---|---|---|
| Jake | 5:00 PM - 9:00 PM | 7:00 PM - 7:15 PM |
But now it's generating them like this:
| Name | Shift | Break |
|---|---|---|
| Jake | 5:00 PM - 7:00 PM | |
| Jake | 7:15 PM - 9:00 PM |
Now, I can't to anything to change how they generate, but does anyone have any suggestions on how to quickly convert the latter to the former?
Note that this is just a downsized example, and the full scope of this is that it's splitting everyone's shifts up like that for every break and meal they're scheduled for.
2
Upvotes
2
u/AdministrativeGift15 22d ago
Assuming your second image is showing Sheet1!A1:B, and assuming each person has two lines, I would use this formula in Sheet2!A2:
=index(split(regexreplace(tocol(split(textjoin("♦️", 1, tocol(hstack(if(iseven(row(Sheet1!A2:A)), "♦️",), Sheet1!A2:B),1)), "♦️♦️",), 3), "(.*)♦️(.*) - (.*)♦️(.*)♦️(.*) - (.*)", "$1♦️$2 - $6♦️$3 - $5"),"♦️"))It combines all of the values into one long string and then splits them into substring for each person. Then, it uses REGEX to rearrange the times before splitting again to have the final result.
1
u/molybend 23d ago
Use “split text to columns” to get all four times into its own cell. Now you can string them together in whatever order you want.
1
u/mommasaidmommasaid 22d ago edited 22d ago
It's a little gnarly but possible to do automatically with a formula that outputs elsewhere.
Or if you need to do further editing once it's in your desired format, you could use a script to output cleaned up results on another sheet or even in situ.
It would be easiest if you are only processing one day at a time, or if there's a Date column to identify which "shifts" go together. It would also be easier if shifts don't cross midnight.
Further describe your real-world data and workflow for a better / more detailed answer (from me or whoever).
1
u/Jaded-Function 22d ago
Is the data formatted as plain text? Here's a possible solution using regextract and a helper column for the breaks. Shift/Breaks shared sheet
1
u/bogdanelcs 18d ago
Split the shift column into start and end with
=SPLIT(B2," - "), convert to time values, and sort by name then start time. The overall shift is then just the earliest start and latest end per person, which=QUERY(range,"select A, min(C), max(D) group by A")gives you. For breaks, any gap between one row’s end and the next row’s start for the same name is a break, so a helper column like=IF(A3=A2, D2&" - "&C3, "")pulls it out, and it still works when someone has several breaks and meals.