Script to reverse a table : I have a spreadsheet for employee schedule (you can see a demo in the link below). As you can see in the "original table" I have 2 rows per day and columns for every shift (Shift A, Shift B ... ).

DEMO TABLE:
[https://docs.google.com/spreadsheets/d/1z8ayTVFA6BSLpV2sEMiTYjBp_Huo0KBeG6sMn6BjBfM/edit?usp=sharing][1]

I need to "reverse" the table extracting every shift for any employee (as you can see in the right side of the demo table "calculated table")

I don't think it's possibile with normal formulas, I tried with "join" formula and some ifs but it's not a working solution in my opinion.

Any idea on how can I write a custom formula in Google App Script? Do you know any workaround with formulas? Can you tell me where can I found some examples?

Notice that, sometimes, employee can have two shift in a single day

Thanks


  [1]: https://docs.google.com/spreadsheets/d/1z8ayTVFA6BSLpV2sEMiTYjBp_Huo0KBeG6sMn6BjBfM/edit?usp=sharing