Summing the Largest Values

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


2

Paul has a list of transactions in a worksheet. Column G contains the amount for each transaction. These transactions can be positive or negative. He needs to derive two sums from the transaction list: the seven largest positive transactions and the seven largest negative transactions. Paul just needs the sums, not any other information about the transactions.

The traditional way to find the largest and smallest values is to use the LARGE and SMALL functions, in this manner:

=SUM(LARGE(G:G,{1,2,3,4,5,6,7}))
=SUM(SMALL(G:G,{1,2,3,4,5,6,7}))

These formulas should work in all versions of Excel. The only thing to keep in mind is that they must be entered as array formulas (Ctrl+Shift+Enter) in Excel 2016 or older versions.

The problem with this approach is that it simply uses the largest and smallest values in the column. It doesn't take into account if those values are actually positive or negative. For example, it will work great if the largest values are {99, 54, 43, 43, 39, 23, 21}. It will not work well, though, if the largest values are {539, 94, 89, -1, -3, -11}. It will sum them, but Paul wanted the seven largest positive values, not just the seven largest values. In this case, there are not seven positive values, so LARGE returns negative values, too. The same issue arises when the values returned by SMALL don't include just negative values.

To get around the "mixed sign" results, you can modify the formulas in this manner:

=SUM(LARGE(IF(G:G>0,G:G),{1,2,3,4,5,6,7}))
=SUM(SMALL(IF(G:G<0,G:G),{1,2,3,4,5,6,7}))

In this case, the values in column G will only be summed if they are positive or negative, respectively. If seven values cannot be returned for the sum, then the formulas return a #NUM! error. This would seem appropriate for Paul's stated purposes.

If you want a formula that returns a sum for up to 7 values, excluding negative or positive values as appropriate, then you need to construct formulas that will only work in Excel 365:

=LET(rng, TRIMRANGE(G:G), vals, FILTER(rng, ISNUMBER(rng) * (rng > 0)), SUM(TAKE(SORT(vals, 1, -1), 7)))
=LET(rng, TRIMRANGE(G:G), vals, FILTER(rng, ISNUMBER(rng) * (rng < 0)), SUM(TAKE(SORT(vals, 1, -1), -7)))

Notice that the formulas use the FILTER function to exclude any non-numeric values in a column (such as a column header or blank cells) and any values less than 0 or greater than 0, respectively.

It should be noted that there are variations on these formulas that could be easily put together. Most variations rely on different ways to get the sequence of 1 through 7, {1,2,3,4,5,6,7}, used in the earlier formulas. For instance, you could replace the array with ROW(1:7) or with SEQUENCE(7). The options, as they say, are multitudinous.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11165) 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

Moving Items On a Menu

Want your copy of Excel to reflect the way you want to work with the interface? Fortunately, you can modify where various ...

Discover More

Noting the Workbook Creation Date

You may want to add, to your worksheet, the date on which a particular workbook was created. Excel doesn't provide a way ...

Discover More

Using the SYMBOL Field

The most common way of adding symbols to a document is to use the Symbol dialog box. There is another way, however, that ...

Discover More

Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!

More ExcelTips (ribbon)

First Value Less Than or Equal to 100

If you need to evaluate a row of values to meet specific criteria, then you'll appreciate the discussion in this tip. It ...

Discover More

Calculating the Distance between Points

Want to figure out how far it is between two points on the globe? If you know the points by latitude and longitude, you ...

Discover More

Finding the First Non-Digit in a Text Value

If you have a string of text that is composed of digits and non-digits, you may want to know where the digits stop and ...

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 two less than 5?

2025-12-16 12:00:43

J. Woolley

For related discussion, see https://excelribbon.tips.net/T009422_Summing_Only_the_Largest_Portion_of_a_Range.html


2025-12-13 11:55:09

J. Woolley

As noted in the Tip, "If seven values cannot be returned for the sum, then the [following] formulas return a #NUM! error."
=SUM(LARGE(IF(G:G>0,G:G),{1,2,3,4,5,6,7}))
=SUM(SMALL(IF(G:G<0,G:G),{1,2,3,4,5,6,7}))
On the other hand, the following formulas return the correct sum even when there are less than seven positive or negative values.
=SUM(LARGE((G:G)*(G:G>0), {1,2,3,4,5,6,7}))
=SUM(SMALL((G:G)*(G:G<0), {1,2,3,4,5,6,7}))


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.