Forum Discussion
How do I change a table with 2 columns where I have repeating values in both columns into a matrix?
All you are trying to do is generated a list of subjects for each student. Unfortunately the current implementation of Excel will simply return an error message "Nested arrays are not supported". Not very helpful when the whole purpose of the calculation is to return a nested array"! A possible solution is to use
=LET(
student, UNIQUE(Name),
SubjectListλ, LAMBDA(n, TOROW(FILTER(Subject, Name = n))),
subjectList, MAPλ(student, SubjectListλ),
SORT(HSTACK(student, subjectList))
)The first line creates a list of distinct student names. The second line defines a function that will return a list of subjects for any given student. The third line uses MAP to return the subject list for each student in turn. This is where the Excel in-built functionality fails. What I have done instead is use a function MAPλ that I wrote to overcome the problem. The final line sorts the data alphabetically by student name, to give
It is complicated but the user need never look at it!