问题
I have an excel sheet with two columns of interest Year and Donations. The year values are 2008,2009,2010 etc...
I would like to get the minimum of all donations for 2009. I have tried
MIN(IF(Year="2009",Donations,"")
The problem with this is for years other than 2009 it falls to "" and hence the min is 0.
Is there a different function I should be using.
回答1:
The formula you have is correct. MIN will ignore text. A couple of things to check:
Make sure the data in Years is really text. If it's a number, you need to remove the quotes around 2009 or it won't find anything.
Make sure you're entering the formula with Control+Shift+Enter, and not just Enter. Excel will put curly braces around the formula in the formula bar indicating it's an array formula.
Make sure you're not actually getting the correct answer. That is, make sure there are no entries of zero for 2009. Seems unlikely you would record a donation of zero, but it's worth a look.
If your Year data is actually text, maybe because it's imported, then it's possible the Donations data is text too. If that's the case use
MIN(IF(Year="2009",Donations*1,""))
The *1 will force the text to a number if possible.
回答2:
Enter this as an array formula (press ctrl-shift-enter rather than just enter to make it an array)
=MIN(IF(<YearRange>=2009,<ValueRange>,""))
回答3:
Create a pivot table with Year as a row and Donations as Data (choose the Minimum option).
来源:https://stackoverflow.com/questions/5134005/excel-min-of-a-subset-of-a-range