Function Problems

How to Return the First Band Selected for Each Test Set in Excel

Khadija KhanKhadija Khan Nov 11, 2026 869 views

Question details

The user needs to extract the first selected band value for each unique test set from a dataset, leaving any subsequent duplicate test set entries completely blank.

How to Return the First Band Selected for Each Test Set in Excel
Product
Spreadsheet
Device & OS
not provided
Scenario
Filtering a dataset to dynamically display a corresponding value only upon the very first occurrence of an item in another column.
Observed behavior
The user requires a formula that can check for the first instance of a test set top-to-bottom and output the corresponding band name, while outputting an empty string for any repeated instances.
Before you start

Identify which column contains your return values (e.g., Column A for Bands) and which column contains your reference identifiers (e.g., Column B for Test Sets). Ensure your dataset starts in row 2 to match the provided formula logic.

Solution 1Recommended

Use IF and COUNTIF Functions to Find the First Occurrence

This solution uses an expanding range inside a COUNTIF function, wrapped in an IF statement, to isolate the very first time a specific test set appears.

By locking the first cell reference ($B$2) and leaving the second reference relative (B2), the COUNTIF range expands dynamically as you drag the formula down the column. When the formula returns a count of 1, it indicates the first appearance of that test set.

1
Select the target output cell

Click on the cell in the first data row where you want the result to appear (for example, cell C2).

2
Input the expanding COUNTIF formula

Type the formula =IF(COUNTIF($B$2:B2,B2)=1,A2,"") directly into the cell or the formula bar.

3
Execute the formula

Press Enter. The cell will display the band name from column A only if this is the first time the test set appears in column B.

4
Fill the formula down

Click and hold the small fill handle at the bottom right corner of the selected cell, then drag it down to apply the formula through the rest of your data rows.

Use IF and COUNTIF Functions to Find the First Occurrence
Column References: If your data is in different columns, adjust 'A2' to point to your Band data column, and '$B$2:B2' to point to your Test Set data column.
Solve directly in WPS Spreadsheet

Master Complex Formulas Easily with WPS Spreadsheet

WPS Spreadsheet fully supports advanced logical and statistical functions like IF and COUNTIF out of the box. You can efficiently manage duplicate data and extract specific values easily using a fast, familiar interface.

  1. 1. Open your data in WPS Spreadsheet: Launch WPS Office and open your workbook containing the bands and test sets.
  2. 2. Insert the logical formula: Select the empty output cell and enter the formula =IF(COUNTIF($B$2:B2,B2)=1,A2,"").
  3. 3. Apply to the whole dataset: Double-click the fill handle in the bottom right corner of the cell to instantly apply the formula to all rows below.
100% compatible with Microsoft Excel formulas like IF and COUNTIF.Easily extract the first occurrence or handle duplicate data dynamically.Lightweight software that loads large datasets quickly without lagging.Free to use with a familiar, easy-to-navigate tabbed interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my formula returning blank for the very first item?

Ensure that the absolute reference ($B$2) points precisely to the first row of your data. If your data headers take up the first two rows and your data starts on row 3, the formula must be updated to $B$3:B3.

Can I use this formula to return text like 'First' instead of a cell reference?

Yes. You can replace the cell reference 'A2' in the formula with your desired text enclosed in quotation marks. For example: =IF(COUNTIF($B$2:B2,B2)=1,"First","").

Does this IF and COUNTIF formula work if my test sets are not sorted together?

Yes. Because the formula counts occurrences dynamically from top to bottom as the range expands, it will always flag the very first time it encounters a specific test set, regardless of how the overall list is sorted.

How do I highlight the first selected band instead of extracting it to a new column?

You can use the logical portion of the formula, =COUNTIF($B$2:$B2,$B2)=1, inside the Conditional Formatting menu as a custom rule to highlight the entire row of the first occurrence.