Forum Discussion
Calculate date diff for all combinations
Hi
I need to calculate the time it takes for trucks to go from one station to another so I can select any origin and destination in my dataset and calculate the average time for all or different trucks that did that route.
This is how the data could look like this. Assume truck 1 started on 00-01-2022:
| Stop | truck number | origin | destination | arrival date |
| 1 | 1 | A | B | 05-01-2022 |
| 2 | 1 | B | C | 10-01-2022 |
| 3 | 1 | C | D | 20-01-2022 |
| 4 | 1 | D | E | 30-01-2022 |
We would need to get all the combinations from origin and destination for the following X destination for a particular origin. It would be great if it could ve a parameter so we say that we want the following table but only from a destination to the next X destinstions (in the example it would be x=4):
| Origin | Destination | Diff Time | truck number |
| A | B | 5 days | 1 |
| A | C | 10 days | 1 |
| A | D | 20 days | 1 |
| A | E | 30 days | 1 |
| B | C | 5 day | 1 |
| B | D | 15 days | 1 |
| B | E | 25 days | 1 |
| C | D | 10 days | 1 |
| C | E | 20 days | 1 |
And few more. Main question would be how to calculate all combinations for x stops in the future. The dataset is huge and I xan not calculate all stops for a truck