Create a Class Combination Matrix in WPS Spreadsheets Without VBA
Question details
The user needs to build a class combination matrix from enrollment records that counts how many students are in each pair of classes, with class totals shown on the diagonal, using formulas instead of VBA or manual Boolean columns.

- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- A teacher or course administrator has student-class enrollment data and wants to summarize class overlap for planning or scheduling.
- Observed behavior
- They want a matrix where each cell represents the number of students attending both the row and column class, with diagonal cells showing total enrollment per class.
Before you begin, confirm your enrollment data is stored in a table with Student and Class columns, and prepare a unique list of class names that can be used as row and column headers.
Use LET, FILTER, and XMATCH to Count Each Class Pair
Use this solution when you need a dynamic matrix that recalculates automatically as enrollment data changes.
This method assumes the enrollment data is in a table named Enrollments with Student and Class columns. The formula filters students for the row class and column class, intersects the two lists with XMATCH, and counts the matches. On the diagonal, it returns the total number of students in that class.
Click Menu > Open in WPS Office and select the workbook containing the Enrollments table.
On a blank sheet, type the unique class list along row 1 starting at B1 and down column A starting at A2.
Select cell B2, type =LET(a,FILTER(Enrollments[Student],Enrollments[Class]=B$1),b,FILTER(Enrollments[Student],Enrollments[Class]=$A2),SUM(--ISNUMBER(XMATCH(a,b)))), and press Enter.
Drag the fill handle from B2 across row 2 and down column B to fill every class-pair cell.

Create a Class Combination Matrix in WPS Spreadsheets Without VBA
Use WPS Spreadsheets to open your enrollment workbook, build a class combination matrix with dynamic array formulas, and save it as a compatible .xlsx file—no VBA or manual Boolean columns required.
- 1. Open your enrollment file: Launch WPS Office, click Menu > Open, and browse to your .xlsx workbook.
- 2. Create the class headers: On a new sheet, enter unique class names across row 1 and down column A.
- 3. Add the formula: Click the first matrix cell and enter the LET, FILTER, and XMATCH formula, then press Enter.
- 4. Fill the matrix: Drag the fill handle across and down to populate all class-pair cells.
- 5. Save your workbook: Click Menu > Save As and choose Excel .xlsx format to keep the file compatible.

Frequently Asked Questions
How do I make the formula use different table or column names?
Replace Enrollments[Student] and Enrollments[Class] with your table name and column names, for example Attendance[Pupil] or Attendance[Course].
Why is the diagonal cell different from other cells?
When the row and column class are the same, both FILTER functions return the same student list, so XMATCH matches every student and the cell shows the total enrollment for that class.
Can I use this matrix if I add a new class later?
Yes. Add the class name to a new row and column header, then copy the formula into the new cells; the calculation updates automatically.
Does the formula require macros or VBA?
No. It uses only worksheet functions, so it runs in WPS Spreadsheets without enabling macros.
What if my enrollment file is .xlsx from Excel?
Open it directly in WPS Spreadsheets, apply the formula, and save it back as .xlsx; formatting and formulas remain compatible.




