Forum Discussion
powebibeginner
4 years agoNew Member
Merging duplicate column ID's and placing specific column as a row
Hi, i have been struggling with how to get this working. I tried merging/grouping/transposing, but i dont seem to be doing it right.
I have a list of students with grades for different subjects:
| ID | First Name | Last Name | Subject | Grade |
| 1 | John | Smith | Math | 8 |
| 1 | John | Smith | Science | 9 |
| 1 | John | Smith | English | 10 |
| 1 | John | Smith | Social Studies | 9 |
| 2 | Steve | Nash | Math | 6 |
| 2 | Steve | Nash | Science | 7 |
| 2 | Steve | Nash | English | 8 |
| 2 | Steve | Nash | Social Studies | 4 |
| 3 | Jamal | Murray | Math | 2 |
| 3 | Jamal | Murray | Science | 3 |
| 3 | Jamal | Murray | English | 9 |
| 3 | Jamal | Murray | Social Studies | 4 |
| 4 | Kelly | Olynk | Math | 7 |
| 4 | Kelly | Olynk | Science | 6 |
| 4 | Kelly | Olynk | English | 8 |
| 4 | Kelly | Olynk | Social Studies | 2 |
I want to merge the students all into one row with the addition of the subjects to the headers:
| ID | First Name | Last Name | Math | Science | English | Social Studies |
| 1 | John | Smith | 8 | 9 | 10 | 9 |
| 2 | Steve | Nash | 6 | 7 | 8 | 4 |
| 3 | Jamal | Murray | 2 | 3 | 9 | 4 |
| 4 | Kelly | Olynk | 7 | 6 | 8 | 2 |
Any help or advice would be appreciated.
Thank you
=Table.Pivot(PreviousStepName,List.Distinct(PreviousStepName[Subject]),"Subject","Grade")
2 Replies
- wdx223_DanielCommunity Champion
=Table.Pivot(PreviousStepName,List.Distinct(PreviousStepName[Subject]),"Subject","Grade")
- powebibeginnerNew Member
Thanks! worked for me!