Function Problems

Sort Unique Semester Labels by Custom Order and Year in Excel

Nimra MalikNimra Malik Dec 2, 2026 869 views

Question details

Create a unique list of semester labels sorted by a custom semester order and then by year.

Sort Unique Semester Labels by Custom Order and Year in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains repeated semester labels that should appear once in a custom-sorted list.
Observed behavior
The desired list places semesters in the specified order, such as Spring before Fall, and sorts years within each semester.
Before you start

Make sure each label has a consistent numeric semester order and year, such as 1 for Spring and 2 for Fall. The formula below assumes these values are stored in an Excel table named Table1 with columns named Term, SemesterOrder, and Year.

Solution 1Recommended

Use a formula to sort unique labels by semester and year

Use this approach in a modern version of Excel that supports dynamic arrays, LET, SORTBY, UNIQUE, and XLOOKUP.

The formula first creates a unique label list, then looks up each label's semester order and year. All occurrences of the same label must have the same order and year.

1
Prepare the table

Select the source data and choose Insert > Table. Name the table Table1 and use the column headers Term, SemesterOrder, and Year.

2
Enter the formula

Click an empty cell outside the table and enter =LET(labels,UNIQUE(Table1[Term]),SORTBY(labels,XLOOKUP(labels,Table1[Term],Table1[SemesterOrder]),1,XLOOKUP(labels,Table1[Term],Table1[Year]),1)).

3
Check the results

Press Enter and check the spilled list. Labels with the lowest semester-order number appear first, with their years in ascending order.

Use a formula to sort unique labels by semester and year
Chronological order is different: Sorting by a real start date gives chronological order, usually by year first. Use the numeric semester-order column when all Spring labels must appear before all Fall labels.
Sort semester labels in WPS

Create a custom-sorted semester list in WPS Spreadsheet

Use WPS Spreadsheet to remove repeated labels from a copy of your data and sort the remaining rows by semester order and year.

  1. 1. Open the workbook: Open your Excel workbook in WPS Spreadsheet and select the worksheet containing the semester data.
  2. 2. Copy the columns: Copy the label, numeric semester-order, and year columns to a blank worksheet.
  3. 3. Remove duplicates: Select the copied range, choose Data > Remove Duplicates, and use the label column as the duplicate criterion.
  4. 4. Sort the list: Select the remaining range and choose Data > Sort. Sort by semester order ascending, then add a year sort level in ascending order. Copy the label column wherever you need the finished list.
Sort semester labels using numeric order and year columnsOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for sorting and duplicate removalKeep the original source data unchanged by working on a copy
microsoft office alternative - wps office

Frequently Asked Questions

How do I put Spring before Fall regardless of year?

Assign Spring an order value of 1 and Fall a value of 2. In Data > Sort, sort by the order column first and the year column second, both ascending.

Can I sort the labels chronologically instead?

Yes. Use a real start-date column and sort it from oldest to newest. This typically groups terms by year first rather than placing every Spring label before every Fall label.

Why does the formula return the wrong order for a label?

Check that every occurrence of the label has the same SemesterOrder and Year values. XLOOKUP uses the first matching row to determine the sort keys.

Will the manually created list update when I add rows?

No. Copy the updated source columns and repeat Data > Remove Duplicates and Data > Sort. The dynamic-array formula can update automatically when rows are added to the Excel table.