I am trying to find a way to create a pivot table in Google Sheets that lists the years as rows, the countries as columns and the number of days lived in each country as the values.
I think the way to go is to add a column to the table that is something like "Days in outbound country", starting from the second row.
| Date & time | Outbound country | Inbound country |
|---|---|---|
| 11/01/2020 17:25 | Germany | France |
| 10/10/2020 12:45 | France | Germany |
| 15/11/2020 17:45 | Germany | Brazil |
| 19/12/2020 20:00 | Brazil | Spain |
| 23/01/2021 18:00 | Spain | Germany |
The issue is that not always the trip is linear (Country A -> Country B ; Country B -> Country A). Sometimes there are other countries in-between.
Could I use the LOOKUP function to search for the previous occurrance of the country? Then how do I calculate the difference for the number of days?