Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Deriving High and Low Non-Zero Values.

Deriving High and Low Non-Zero Values

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


2

There may be times when you need to derive the smallest (or largest) value from a range, unless the smallest (or largest) value is zero. For instance, you might have a range of values such as {0, 3, 1, 4, 2}. In this case, the lowest value is zero, but the value you really want returned is 1.

There is no intrinsic function within Excel to return a value as stipulated here. However, you can create a formula that will do the trick. Assuming that the range of values you want to analyze are in C4:C8, the following formula will return the lowest non-zero value:

=IF(MIN(C4:C8)=0,SMALL(C4:C8,COUNTIF(C4:C8,"=0")+1),MIN(C4:C8))

This formula uses the MIN function to determine if the lowest value in the range is zero. If it is, then the SMALL function is used to derive the lowest value, excluding the zeros. (The COUNTIF function returns the number of zeros in the range, and therefore tells SMALL which item from the range to pick.)

A small change to the formula allows it to be used to return the largest non-zero number in a range:

=IF(MAX(C4:C8)=0,LARGE(C4:C8,COUNTIF(C4:C8,"=0")+1),MAX(C4:C8))

These formulas will work for any range, unless the range is made up entirely of zeros. In that instance, a #NUM! error is returned.

If you are using Excel 2019 or Excel in Office 365, you can use the new MINIFS function. It would be used in this manner for this example:

=MINIFS(C4:C8,C4:C8,"<>"&0)

More information on the MINIFS function can be found on this Microsoft Office support page:

https://support.office.com/en-gb/article/minifs-function-6ca1ddaa-079b-4e74-80cc-72eef32e6599

If you prefer to use array formulas, then you can make the formula much shorter. This version returns the lowest non-zero value:

=MIN(IF(C4:C8=0,9^9,C4:C8))

Remember to enter it using Ctrl+Shift+Enter. It also suffers from a problem if all the values in the range are 0; in that case it returns 387420489, which is 9^9. (It would also return that value if all the values in the range were greater than 387420489.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9750) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Deriving High and Low Non-Zero Values.

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

Understanding Views

Need to display your worksheet in different ways? A quick way to do this is to create views, as described in this tip.

Discover More

Setting Grammar-Checking Options

When Word checks the grammar it thinks you are using in your prose, it follows a set of rules. Fortunately, the program ...

Discover More

Merging and Printing a Series of Documents

Do you need to merge and print a number of documents in a particular order? Perhaps the best approach is to record a ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Pulling a Phone Number with a Known First and Last Name

When using an Excel worksheet to store data (such as names and phone numbers), you may need a way to easily look up a ...

Discover More

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

Checking for Duplicate Rows Based on a Range of Columns

When working with data in Excel, you might want to figure out which rows of data represent duplicates of other rows. If ...

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 four minus 0?

2021-08-04 09:09:07

Mark Winfield

Hi Allen,

Thanks for your many useful tips - I've followed your site for years and always enjoy reading the tips you write.

A question on this current tip 'Deriving High and Low Non-Zero Values'; I follow the logic of your first formula in the tip but wonder whether you could halve its length by getting rid of the 'IF' and the two 'MIN' functions, and just use:

=SMALL(C4:C8,COUNTIF(C4:C8,"=0")+1)

Have I missed something? Kind regards, Mark


2021-07-31 10:23:39

J. Woolley

You can also use the MINIF and MAXIF functions in My Excel Toolbox:
=MINIF(C4:C8,"<>0")
=MAXIF(C4:C8,"<>0")
MINIF and MAXIF (which are not built-in Excel functions) are designed analogous to SUMIF (which is built-in).
See https://sites.google.com/view/MyExcelToolbox/


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.