Forum Discussion
Calculating hours using pivot table
Hi,
I'm making a personell planning sheet and I want to calculate the sum of hours teachers give lessons. I have 2 tables and my data is formatted like this (simplified)
| Lesson name | Hours | Teacher 1 | Teacher 2 |
Lesson 1 | 2 | Paul |
|
Lesson 2 | 3 | Pete |
|
Lesson 3 | 2 | Paul | Pete |
| Teacher name | Max working hours |
| Paul | 10 |
| Pete | 15 |
Now I want to create an overview of how many hours each teacher is teaching using a pivot table.
This is easy when there is just one Teachter collumn but I need to calculate the sum using both teacher collumns...
I need to overview to be something like this:
- Paul -> Lesson 1 + Lesson 3 = 4 hours
- Pete -> Lesson 2 + lessen 3 = 5 hours
Then the next step is to use a metric or KPI to calculate if each teacher is exceeding their max working hours...
Can anybody hlelp me with these problems?
Thanks!
2 Replies
I think you need to make the table like this first. With that dataset it is up to you how you do next steps for your actual needs. Yo
Lesson Hours Teacher Lesson 1 2 Paul Lesson 2 3 Pete Lesson 3 2 Paul Lesson 3 2 Pete
1. Convert the Lesson table to a TableSelect any cell in the Lesson table
Press Ctrl + T
Confirm “My table has headers”
2. Load into Power QueryWith the table selected
Go to Data → From Table/Range (Power Query Editor opens)
3. Unpivot the Teacher columnsHold Ctrl
Select Teacher 1 and Teacher 2
Right-click → Unpivot Columns
4. Clean upDelete the Attribute column
Rename Value → Teacher
Close and load
- mathetesGold Contributor
Your inquiry has been up for several days without a reply. I can't speak for others with certainty, but from my perspective I suspect that the reason for the lack of replies is that the sample data you do give is far too simple. Far too simple to create a Pivot Table from; so in effect you're asking anybody who might want to offer assistance to create their own more complete set of data.
You would help us help you by posting a more representative set of data (still no real names) with multiple teachers, multiple classes, etc. If you're not able to attach an actual Excel workbook to your reply in this forum, put it onto Google Sheets or the equivalent and paste a link here.