Photo by Roberto Nickson on Unsplash

How To Coda Breaks in a Time Table

Calculating breaks for bus drivers in the public transport

The context

My mission was to create time tables for drivers based on a selected time frame and the lines to drive. The selected days have various attributes like it is a weekday or weekend, it is holiday or even a school holiday. All these variations matter in our planning. To be clear, this is not the distribution of drivers over available lines, that is a different story. We assume that we know the driver per line and all we want to show is the start and end time of a working day. Part of the working day are the breaks. In our context they matter quite a lot for they are sometimes rather long, read multiple hours. A working day stretches from early in the morning until late in the evening, while the factual driving time though substantial, is not close to the length of the working day.

Step 0 → relevance of If statement

A service stands for leaving the bus depot and getting back to it. Sometimes we have one or even three per day, most however two. The breaks are periods between these services. A day with one service, has no break.

The time of each service

Step 01 → Filtering

Often you have two services per day. This implies we have to filter on the information that ties schedules together. We get this information by filtering on the lignes (combi of line number, days and period). Please note that dates do not play a role in this set-up. This is a date independent approach.

Getting the lines perd day

Step 01

The first step is using a filter to bring together schedules for one specific day type. In the example you see the standard school period (I guess your French is well enough to understand this):


Step 02

We combine the arrival and departure times using a ListCombine() and a Sort() to ensure the proper order between sub lists.

Getting the time range

Step 03

We apply the logic of a virtual index to align each time slot with a virtual number and we use the Sequence() function to get the job done.

Create a Virtual Index

Step 04

The virtual index is applied to subtract the time slots. On purpose you see the final result (the breaks) , but also the column Les Trajets. See next point.

subtract time slots

Step 05

You see that we have all the time frames in a day, but we only need the breaks. That is a sub set. We already developed the duration of each schedule per day. This information we bring into play. We can either reference the column with this information or recalculate. We go for the latter. We first name the work so far as AllTimeFramesPerDay. Next we define the Schedules, this is a copy — paste of the previous work.

The basic ingredients

Step 06

Our last step is to relate all the time frames with the schedules to get the breaks. We use a filter as you see below and we only want the part that are ‘not’.

The last part
Gabs in the planning
Christiaan on: How To Coda Breaks in a Time Table



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Christiaan Huizer

I use Coda mainly for (HR) planning & (budget) calculations. Follow me to learn how to Coda with numbers. I blog at least once per week.