Creating a SUMIFS Formula to Show Last Row Based on Criteria in Tech Support Site

Abstract: Find the last row number matching multiple criteria in Excel using a LOOKUP formula instead of SUMIFS which only returns totals.

Created: 2026-08-21 by
To display the last row number that matches multiple criteria using SUMIFS, you must combine it with MATCH and INDEX functions. The standard SUMIFS function calculates totals but cannot identify positions. By nesting MATCH inside INDEX, you can locate the final entry where all specified conditions are met simultaneously. This approach ensures accurate data analysis for dynamic datasets without manual scrolling.

Understanding the Limitation of SUMIFS

The SUMIFS function is designed exclusively for aggregation. It adds up values in a range based on one or more criteria ranges and their corresponding criteria. While powerful for financial summaries or inventory counts, it returns a single numeric result representing the sum. It does not return the cell address, row number, or any positional information about where those matching values exist within your dataset.

When you need to find the last occurrence of a specific set of conditions, relying solely on SUMIFS is insufficient. You require a method to search through your data structure and return an index. This is where array formulas and lookup functions become essential tools in Excel and Google Sheets for advanced data manipulation tasks.

Constructing the Lookup Logic

To find the last row, you need to evaluate each row against your criteria and assign a boolean value (TRUE or FALSE). Then, you identify the position of the last TRUE value. The core logic involves creating an array that checks if every criterion is met for each row. If all criteria match, the array element is 1; otherwise, it is 0.

Consider a dataset in columns A through C, where Column A contains dates, Column B contains product names, and Column C contains sales figures. You want to find the last row where the date is "2023-10-01" and the product is "Widget". You will create a logical test that compares these cells across the entire range. This creates a vertical array of 1s and 0s corresponding to each row in your data table.

Implementing the Formula Step-by-Step

The most robust way to achieve this is by combining MATCH, INDEX, and ROW functions. Here is the step-by-step construction of the formula:

  1. Create the Logical Array: Use multiplication (*) to join multiple criteria. For example: (A2:A100="2023-10-01") * (B2:B100="Widget"). This produces an array of 1s where both conditions are true and 0s elsewhere.
  2. Identify the Last Match: Use the MATCH function with the value 1 and the LOOKUP function to find the last 1 in the array. Alternatively, use MAX on the row numbers of the matches.
  3. Return the Row Number: Wrap the logic in INDEX or direct calculation to output the absolute row number.

A common efficient formula structure is:

=INDEX(ROW(A2:A100), MATCH(1, (A2:A100="2023-10-01")*(B2:B100="Widget"), 0))

Note: In older versions of Excel, this requires pressing Ctrl+Shift+Enter to confirm as an array formula. In modern Excel with dynamic arrays, simply pressing Enter works. To ensure you get the LAST row, you might need to reverse the logic or use LARGE instead of SMALL/default MATCH.

A more reliable version for finding the LAST occurrence is:

=LOOKUP(2, 1/((A2:A100="2023-10-01")*(B2:B100="Widget")), ROW(A2:A100))

This technique uses the fact that LOOKUP searches for the largest value less than or equal to the lookup value. By dividing 1 by the boolean array, you get 1 for matches and #DIV/0! for non-matches. LOOKUP ignores errors and finds the last 1, returning the corresponding row number from the third argument.

Handling Errors and Empty Cells

If no rows match your criteria, the formula will return an error such as #N/A or #DIV/0!. It is crucial to wrap your formula in an IFERROR function to handle these cases gracefully. For example:

=IFERROR(LOOKUP(2, 1/((A2:A100="2023-10-01")*(B2:B100="Widget")), ROW(A2:A100)), "No Match Found")

This ensures that your dashboard or report remains clean even when data is incomplete. Additionally, be mindful of leading or trailing spaces in text criteria, as they can cause mismatches. Use the TRIM function if necessary to clean your input data before applying the lookup logic.

Performance Considerations

Using full column references like A:A in array formulas can significantly slow down calculation times in large datasets. It is best practice to define a specific range, such as A2:A1000, or convert your data into an Excel Table. Tables automatically expand ranges, making your formulas dynamic without needing to update the range addresses manually.

For very large datasets exceeding 100,000 rows, consider using Power Query or VBA macros for better performance. However, for typical business reports, the array formula approach described above is sufficient and provides real-time updates as new data is added.

SUMIFS Producing Different Answers: A Tech Support Guide discusses related issues with criteria evaluation that often accompany complex lookups. Understanding how Excel evaluates criteria helps prevent unexpected results when building these multi-condition arrays.

Frequently Asked Questions

Can I use SUMIFS to return the row number directly?

No, SUMIFS only returns the summed value of cells that meet the criteria. It has no capability to return positional data like row numbers or cell addresses. You must use lookup functions like INDEX, MATCH, or LOOKUP in combination with logical tests to retrieve the row index.

What if my criteria include wildcards or partial text matches?

You can use wildcard characters like asterisks (*) in your criteria within the logical array. For example, *("Product" & "*") will match any cell containing "Product". Ensure that the wildcard syntax is correctly applied within the parentheses of your boolean expression to avoid errors.

Why does my formula return the first match instead of the last?

Standard MATCH functions typically find the first occurrence. To find the last match, you should use the LOOKUP function trick with division by the boolean array, or use LARGE on the row numbers of matching entries. The LOOKUP method is generally preferred for its simplicity and reliability in finding the final instance.

How do I handle blank cells in my criteria range?

Blank cells are treated as zero-length strings. If your criteria expect text, blanks will not match unless explicitly included. You can add a condition to allow blanks, such as (B2:B100="") + (B2:B100="Widget"), ensuring that either an empty cell or the specific text triggers the match.

Find Missing Rows in Two Datasets Based on Multiple Criteria: A Tech Support Solution provides context on managing discrepancies that may arise when identifying specific rows in larger data environments.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More