简体   繁体   English

Excel 公式返回最小值,考虑空单元格

[英]Excel Formula returning the smallest value, taking into account empty cells

I have 4 dates across a table, I want to return the smallest date so have used the below, however if that cell is blank I want the cell displaying the date to be blank?我在一个表格中有 4 个日期,我想返回最小的日期,所以使用了下面的日期,但是如果该单元格为空,我希望显示日期的单元格为空? This is what I've tried:这是我尝试过的:

=SMALL(D2:K2,1,D2,"")

It does not work.这是行不通的。

I am not sure if I understand your question correctly.我不确定我是否正确理解你的问题。

If you wish to display the lowest date in the range or - if any of the cells are blank - a blank cell, you might use this formula.如果您希望显示范围内的最低日期,或者 - 如果任何单元格为空白 - 一个空白单元格,您可以使用此公式。 It checks if the number of non-blank cells is 0 and results either in the minimum date or a blank.它检查非空白单元格的数量是否为 0 并导致最小日期或空白。

=IF(COUNTBLANK(D2:K2)=0,SMALL(D2:K2,1),"")

您需要使用 IF:

=IF(D2="","",SMALL(D2:K2,1))

This is the array formula ( Ctrl + Enter to run it), that is needed:这是数组公式( Ctrl + Enter运行它),这是需要的:

=IF(ISERROR(MATCH(TRUE(),ISBLANK(A1:A4),0)),SMALL(A1:A4,1),"")

The idea is the following:想法如下:

  • get the first cell in the range, which is not filled out with the array formula =MATCH(TRUE(),ISBLANK(A1:A4),0) .获取范围中的第一个单元格,该单元格未使用数组公式=MATCH(TRUE(),ISBLANK(A1:A4),0)填充。 It will either return a the position of the empty cell or N/A error, if there is no such cell.如果没有这样的单元格,它将返回空单元格的位置或N/A错误。
  • put =IF(ISERROR) to check whether there is an empty position in the range, returning an error. put =IF(ISERROR)检查范围内是否有空仓,返回错误。
  • unite the formula with =SMALL(A1:A4,1) , if there is no empty cell.如果没有空单元格,则将公式与=SMALL(A1:A4,1)

Formulas are in German, but I hope it is understandable:公式是德语,但我希望它是可以理解的:

在此处输入图片说明

=IF(ISBLANK(D2),"",MIN(D2:K2))

You can use the union of two formulas:您可以使用两个公式的并集:

The count.if() and the small() , like I did on this case: count.if()small() ,就像我在这种情况下所做的那样:

=IF(COUNT.IF(Q31:Q38;"")>0;"";SMALL(Q31:Q38)) , where Q31:Q38 is my interval. =IF(COUNT.IF(Q31:Q38;"")>0;"";SMALL(Q31:Q38)) ,其中Q31:Q38是我的间隔。

On count.if we count the number of blank cells (equals to "");count.if我们计算空白单元格的数量(等于“”);

On ìf , we verify if our counter is > 0. If it is, our cell receives the "" value.ìf ,我们验证我们的计数器是否 > 0。如果是,我们的单元格会收到 "" 值。 If it isn't, it receives the smaller data value.如果不是,它接收较小的数据值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM