Function Problems

Excel Formula to Match Two Conditions and Compare Values

Maira MehtabMaira Mehtab Dec 2, 2026 868 views

Question details

The user needs a formula that matches two criteria and returns a value only when one cell is greater than or equal to another.

Match Two Conditions and Compare Values in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Compare B26 with B27, then match B24 and B25 against columns A and B and return the corresponding value from column F.
Observed behavior
The desired result is zero when B26 is less than B27, the matching value from column F otherwise, or a blank when no match is found.
Before you start

Check that B24 and B25 contain the lookup criteria and that B26 and B27 contain comparable values. Confirm that rows 33 through 38 contain the criteria in columns A and B and the return values in column F.

Solution 1Recommended

Use IF and XLOOKUP to match both criteria

Use this formula in Excel for Microsoft 365 to compare the two cells and return the first matching value.

1
Select the result cell

Click the cell where you want the result to appear.

2
Enter the formula

Type =IF(B26<B27,0,XLOOKUP(1,(B24=$A$33:$A$38)*(B25=$B$33:$B$38),$F$33:$F$38,"")) in the formula bar and press Enter.

3
Check the result

Change the values in B24 through B27 to test the formula. It returns 0 when B26 is less than B27; otherwise, it returns the first matching value from column F or a blank if no row matches.

Use IF and XLOOKUP to match both criteria
How the criteria work: Multiplying the two comparison arrays produces 1 only for rows where both criteria match. When B26 equals B27, the lookup is performed.
Work with formulas in WPS Spreadsheets

Match Two Conditions in WPS Spreadsheets

Use a nested IF formula in WPS Spreadsheets to compare two cells and return the value from the first row that matches both criteria.

  1. 1. Open your spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
  2. 2. Check the source cells: Enter or verify the criteria in B24 and B25, the comparison values in B26 and B27, and the lookup data in A33:B38 and F33:F38.
  3. 3. Enter the formula: Select an empty result cell and enter =IF(B26<B27,0,IF(AND(B24=A33,B25=B33),F33,IF(AND(B24=A34,B25=B34),F34,IF(AND(B24=A35,B25=B35),F35,IF(AND(B24=A36,B25=B36),F36,IF(AND(B24=A37,B25=B37),F37,IF(AND(B24=A38,B25=B38),F38,""))))))) in the formula bar, then press Enter.
  4. 4. Verify the result: Check the result cell: it should show 0 if B26 is less than B27, the first matching value from column F otherwise, or a blank if no row matches.
Match two criteria and compare values in one formulaOpen and edit Microsoft Excel XLSX filesUse familiar spreadsheet cells and formula controlsWork with spreadsheets in a free office suite
microsoft office alternative - wps office

Frequently Asked Questions

What happens when B26 equals B27?

The formula performs the lookup because the test B26<B27 is false when the values are equal.

What does the formula return if neither row matches both criteria?

It returns a blank string. In the XLOOKUP formula, the final "" argument specifies the result when no match is found.

What if more than one row matches both criteria?

Both formulas return the value from the first matching row in the specified range.

Can I use the formula without XLOOKUP?

Yes. Enter the nested IF and AND formula in the result cell. It checks each row individually, so you must add conditions for any rows beyond row 38.