I have the following sample data
and need to output with a single formula the following result
which is the count of persons for each pair of courses.
I tried the following formula
=LET(
ids, A2:A19,
courses, B2:B19,
uniqueCourses, UNIQUE(courses),
courseRows, INDEX(uniqueCourses, SEQUENCE(ROWS(uniqueCourses), 1)),
courseCols, TRANSPOSE(courseRows),
countMat, MAP(courseRows, courseCols, LAMBDA(cRow,cCol,
SUM( (courses=cRow) * (courses=cCol)))),
countMat)
but got a bunch of #N/A errors.
Any help, suggestions or new formula, will be appreciate.
Thanks in advance
ID | Course |
1000 | a |
1000 | b |
1000 | c |
1001 | a |
1001 | b |
1001 | d |
1002 | a |
1002 | c |
1002 | d |
1003 | a |
1003 | e |
1003 | f |
1004 | a |
1004 | c |
1004 | f |
1005 | a |
1005 | d |
1005 | f |
a | b | c | d | e | f | Total | |
a | 6 | 2 | 3 | 3 | 1 | 3 | 18 |
b | 2 | 2 | 1 | 1 | 0 | 0 | 6 |
c | 3 | 1 | 3 | 1 | 0 | 1 | 9 |
d | 3 | 1 | 1 | 3 | 0 | 1 | 9 |
e | 1 | 0 | 0 | 0 | 1 | 1 | 3 |
f | 3 | 0 | 1 | 1 | 1 | 3 | 9 |
Total | 18 | 6 | 9 | 9 | 3 | 9 | 54 |
I tried the following formula
=LET(
ids, A2:A19,
courses, B2:B19,
uniqueCourses, UNIQUE(courses),
courseRows, INDEX(uniqueCourses, SEQUENCE(ROWS(uniqueCourses), 1)),
courseCols, TRANSPOSE(courseRows),
countMat, MAP(courseRows, courseCols, LAMBDA(cRow,cCol,
SUM( (courses=cRow) * (courses=cCol)))),
countMat)
but got a bunch of #N/A errors.
Any help, suggestions or new formula, will be appreciate.
Thanks in advance
Last edited by a moderator: