Listing the Top Five Transactions

Written by Allen Wyatt (last updated March 1, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


1

Terri has a list of transactions in a worksheet. The first column is a customer name and the second is the transaction amount. Terri knows she could sort or filter the data to determine the top five transactions. However, she wonders if the top five customers and the transaction amount could actually be returned by a formula.

Yes, it is possible to do this and there are many different ways you can approach the problem. In this tip I'm going to look at only a few of those approaches.

First, though, let's make the assumption that the customer names are in column A and that cell A1 has a header in it, such as "Customer." Further, column B contains a header of "Amount" and the rest of the column contains the amounts for each corresponding customer in column A. (See Figure 1.)

Figure 1. Sample data for testing formulas.

Now, let's take a look at an approach that will work in all versions of Excel. Start by placing the values 1, 2, 3, 4, 5 in cells D2:D6. These are your "rank" indicators. Then, in cell F2 you can place the following formula:

=LARGE(B:B,D2)

Copy this formula down to cell F6, and you end up with the five largest transactions in F2:F6. This is because the LARGE function returns the Nth largest value from a range, where the second parameter indicates the rank—in this case 1, 2, 3, 4, or 5.

Now all you need to do is to grab the names related to those transaction amounts. You can do that by putting this formula into cell E2:

=INDEX(A:A,MATCH(F2,B:B,0))

Copy this down to cell E6. The MATCH function matches the amounts in column F against the amounts in column B, and then the INDEX function pulls the corresponding name from column A. You end up with the desired names and transaction amounts in E2:F6. You can even put headers in cells D1:F1, if desired, and format as necessary. (See Figure 2.)

Figure 2. Pulling the top five transactions.

If you are using Excel 2021, 2024, or Excel in Microsoft 365, then you can rely on the newer worksheet functions that are available. A single formula can be used to return the desired information. Here's the one I would place in cell E2:

=FILTER(A2:B1000, B2:B1000 >= LARGE(B2:B1000,5))

The key here is to make sure that the ranges specified include all of the rows in your data. In this case, the range evaluated is A2:B1000, but you can adjust this as needed. The formula returns the top five transactions, though it may return more if there are duplicate transaction amounts in the top five. They are returned in the same order that they appear in the original data. If you would, instead, like them sorted in descending order by the transaction amount, you can wrap the formula in the SORT function:

=SORT(FILTER(A2:B1000,B2:B1000>=LARGE(B2:B1000,5)),2,-1)

Here's another approach that will work in Excel 2021, 2024, and Excel in Microsoft 365, relying on both the SORT and SEQUENCE functions:

=INDEX(SORT(A2:B1000,2,-1), SEQUENCE(5),{1,2})

If you are using Excel in Microsoft 365, then you will have access to the TAKE function, which can shorten the formula even more:

=TAKE(SORT(A2:B1000,2,-1),5,2)

This formula provides a sorted array of the cells, in descending order based on the transaction amount, and then "takes" the first five rows and two columns.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9261) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Word Slow to Open Documents

If you've noticed a slowdown in Word when it is opening a document, you probably would like to speed up the operation. ...

Discover More

Faster Text File Conversions

Want to make your importing of text data faster than ever? Here are some ideas you can apply right away.

Discover More

Setting Tab Stops Using the Tabs Dialog Box

Aligning different lines in your document is easy. Using the tab stops feature in Word, you can set four different types ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Cell and Name References in COUNTIF

The second parameter of the COUNTIF function is used to specify the criteria to be used when determining what should be ...

Discover More

Projects in Process for Each Day in a Range of Dates

If you use Excel to track projects on which you are working, you may want to determine how many projects were in-process ...

Discover More

Limiting a Calculated Value to a Range

If you want to limit what is returned by a formula to something between lower and upper boundaries, the solution is to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 7?

2025-03-02 15:41:38

Erik

One thing to note about the first method discussed, using LARGE and INDEX. If there are two people with the exact same amount, the first person will show up in the top five list twice and the second person will not be in the list.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.