Table of Contents
Use XLOOKUP to retrieve a matching value, SUMIFS or COUNTIFS to summarize qualifying rows, and FILTER to return matching records. These are four functions covering three common jobs. Choosing the right one avoids repeated manual searches and filters.
Set up the example data
The formulas below assume headers in row 1 and data in rows 2–200, with these columns:
| Column | Meaning |
|---|---|
| A | Region |
| B | Country |
| C | Category |
| D | Sales channel |
| I | Order ID |
| J | Unit price |
| L | Sales amount |
Change the ranges to match your sheet. The examples use commas as argument separators; some regional settings require semicolons. XLOOKUP and FILTER require a version that supports them, such as Microsoft 365 or Excel 2021 and later. XLOOKUP is not available in Excel 2016 or 2019.
1. XLOOKUP: find an order's sales amount
Enter the order ID in O2, then use:
=XLOOKUP(O2,I2:I200,L2:L200,"Not found")

The formula searches column I and returns column L from the matching row. Change the value in O2 to search for another order. Exact matching is the default, and the normal search returns the first match; duplicate IDs therefore need attention.

If the ID exists but is not found, check for extra spaces or a number stored as text. Do not use an approximate match just to suppress an unexpected result. See Microsoft's XLOOKUP reference and these Excel data lookup options.
2. SUMIFS and COUNTIFS: summarize several conditions
To total sales amounts for Asian orders with a unit price over 150 and the Online sales channel:
=SUMIFS(L2:L200,A2:A200,"Asia",J2:J200,">150",D2:D200,"Online")
All three conditions must be true on the same row. SUMIFS adds the corresponding sales amount, not the unit price. Its sum range comes first; each condition then uses a range-and-criterion pair.
To count qualifying rows instead:
=COUNTIFS(A2:A200,"Asia",J2:J200,">150",D2:D200,"Online")
This counts orders only if each row represents one order. If an order occupies multiple line items, it counts those rows rather than distinct IDs.
For countries beginning with T, excluding the Fruits category:
=COUNTIFS(B2:B200,"T*",C2:C200,"<>Fruits")The asterisk matches any following characters, while <> means “not equal.” These criteria are not case-sensitive. Hidden spaces and inconsistent numeric types are more likely problems than capitalization. Keep all related ranges the same size; Microsoft's SUMIFS guide explains the argument order.
3. FILTER: return matching values or rows
To return sales amounts for rows whose unit price is at least 600:
=FILTER(L2:L200,J2:J200>=600,"No match")
The condition tests column J; it does not test the total sales amount in L. The third argument supplies a result when no row qualifies.

To return full records for unit prices at least 600 or the Online channel, combine conditions with +:
=FILTER(A2:N200,(J2:J200>=600)+(D2:D200="Online"),"No match")For records satisfying both conditions, use *:
=FILTER(A2:N200,(J2:J200>=600)*(D2:D200="Online"),"No match")

Each comparison is enclosed in parentheses. Leave empty cells for the returned array to spill into; blocked output can cause a #SPILL! error. See the dedicated FILTER tutorial for more examples.
Sort the filtered records
With a category such as Meat in O2, this returns its records sorted by country, the second column of A:N:
=SORT(FILTER(A2:N200,C2:C200=O2),2,1)
The final 1 requests ascending order; use -1 for descending. If there are no matching rows, this version returns an error. To show a message for that case, test first:
=IF(COUNTIF(C2:C200,O2)=0,"No match",SORT(FILTER(A2:N200,C2:C200=O2),2,1))Check a few known rows manually before relying on a report. Correct syntax cannot compensate for references pointing at the wrong column.

Reader Comments 0
Sign in with email or Google to join the discussion.