Imagine a multi column exam invigilation schedule with the following information
- S. No.
- Name of staff
- Designation of staff member
- Two columns for each day on which there is an exam – one for Morning and another for Afternoon
- A * under each column if that particular staff member has to be an invigilator during that time period
S. No. | Name of staff | Designation | 09/11/2017-Morning | 09/11/2017-Afternoon | 10/11/2017-Morning | 10/11/2017-Afternoon |
1 | Tom | Lecturer | * | * | * | |
2 | Sam | Lecturer | * | * |
This dataset stretches into many more columns. So if the exams last for 15 days, there will be 30 columns. The objective is to condense the column expanding dataset into a 5 column one – S. No., Name of Staff, Designation, Morning and Evening. Under the Morning and Evening columns, the different dates have to be separated by commas in that one single cell. The expected result is:
Name of staff | S. No. | Designation | Morning | Afternoon |
Tom | 1 | Lecturer | 09/11/2017, 10/11/2017, 11/11/2017, 13/11/2017, 14/11/2017, 16/11/2017, 17/11/2017 | 10/11/2017, 13/11/2017, 14/11/2017, 15/11/2017, 16/11/2017, 17/11/2017 |
Sam | 2 | Lecturer | 09/11/2017, 13/11/2017, 15/11/2017, 16/11/2017 | 09/11/2017 |
I can think of 3 ways to solve this problem. Here’s a brief about each of those methods:
- Using Power Query and Excel’s functions – Using Power Query, one can first unpivot the data and then use the TEXTJOIN() function. This would be an array formula.
- Using Power Query only – Using Power Query, one can first unpivot the data and then modify the code to concatenate all dates in a single cell for that invigilator. One can then Pivot the data in Power Query itself
- Using Power Query and PowerPivot – Using Power Query, one can first unpivot the data and then use the CONCATENATEX() function of the PowerPivot.
As you can observe, the common thread in all solutions is that one has to first unpivot the dataset.
You may refer to all my 3 solutions in this workbook.
Prepare an invigilation schedule for each teacher by different time periods
{ 5 Comments }