简体   繁体   English

Excel数组公式多个条件空字符串

[英]Excel Array Formula Multiple Conditions Empty String

I have the columns 我有专栏

  • B4 (This Sheet Column B) = Part# B4(本表B栏)=部分#
  • Database A = Date 数据库A =日期
  • Database C = Part# 数据库C = Part#
  • Database AA = Text Comment 数据库AA =文本注释

With the following formula, I want to look, for the comment field with the most recent date that is not empty and return that value. 使用以下公式,我想查看具有最新日期非空的注释字段并返回该值。 In case an error is returned, I just want an empty string returned: 如果返回错误,我只想返回一个空字符串:

     =IFERROR(INDEX(Database!AA$2:$AA$5000;MATCH(MAX(IF(""<>
Database!$AA$2:$AA$5000;IF(B4=Database!$C$2:$C$5000;Database!$A$2:$A$5000)))
&B4;Database!$A$2:$A$5000&Database!$C$2:$C$5000;0));"")

The problem however is, that if I only check for either the most recent date, or un-empty cells, the latest row is returned. 但问题是,如果我只检查最近的日期或非空单元格,则返回最新的行。 If, however I mix the two conditions I get blank cells accross the board. 但是,如果我混合这两个条件,我会在整个电路板上找到空白单元格。

Anybody an idea on how to combine those two conditions with array formulas? 有人想知道如何将这两个条件与数组公式结合起来吗? (I know, VBA would make my life much easier here, but I must not use anything but self-updating formulas) (我知道,VBA会让我的生活变得更轻松,但我不能使用任何东西,只能自我更新公式)

This can be done without CSE using INDEX with the AGGREGATE¹ function providing the cyclic processing much as SUMPRODUCT does without entering as an array formula. 这可以在没有CSE的情况下使用INDEXAGGREGATE¹函数完成,提供循环处理,就像SUMPRODUCT一样,无需作为数组公式输入。 Like an array formula, the number of rows processed should be minimized to avoid calculation lag. 与数组公式一样,应最小化处理的行数以避免计算延迟。

AGGREGATE is first used to find the maximum date based on the part number and non-blank comment; AGGREGATE首先用于根据零件编号和非空白注释查找最大日期; a form of pseudo-MAXIF. 一种伪MAXIF形式。 That value is used in a second AGGREGATE to return a row number to an INDEX of the comments column that also matches the part number and non-blank comment. 该值在第二个AGGREGATE中用于将行号返回到注释列的INDEX,该列也与部件号和非空注释匹配。

In C13 as a standard formula, 在C13中作为标准配方,

=INDEX(AA:AA, AGGREGATE(15, 6, ROW(A$1:INDEX(A:A, MATCH(1E+99,A:A )))/((C:C=B13)*(A:A=AGGREGATE(14, 6, A$1:INDEX(A:A, MATCH(1E+99,A:A ))/((C$1:INDEX(C:C, MATCH(1E+99,A:A ))=B13)*SIGN(LEN(AA$1:INDEX(AA:AA, MATCH(1E+99,A:A ))))), 1))*SIGN(LEN(AA$1:INDEX(AA:AA, MATCH(1E+99,A:A ))))), 1))

max_date_two_conditions


¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions. ¹AGGREGATE功能是在Excel 2010中引入的。它在早期版本中不可用。

² Array formulas need to be finalized with Ctrl + Shift + Enter↵ . ² 需要使用Ctrl + Shift + Enter↵最终确定数组公式。 If entered correctly, Excel with wrap the formula in braces (eg { and } ). 如果输入正确,Excel将公式括在大括号中(例如{} )。 You do not type the braces in yourself. 您不要自己键入大括号。 Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. 一旦正确进入第一个单元格,就可以像任何其他公式一样向下或向右填充或复制它们。 Try and reduce your full-column references to ranges more closely representing the extents of your actual data. 尝试并减少对更接近表示实际数据范围的范围的全列引用。 Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. 数组公式以对数方式计算计算周期,因此将参考范围缩小到最小值是一种好习惯。 See Guidelines and examples of array formulas for more information. 有关更多信息,请参阅数组公式的准则和示例

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

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