arrays - 当源表只有一行时,使用 MATCH 的数组公式不会给出结果

标签 arrays excel excel-formula

当源表有一行时,以下数组公式结果为#N/A,但当表有超过 1 行时(即使有两行,其中一行是空)。

作为解决方法,我(在 Power Query 查询中)向相关表 (tblRCGRouteMasterCoProduct) 添加了一个空行。

如何解决这个问题?

=MATCH(1;(tblRCGRouteMasterCoProduct[RoutingCropGroupCode]="BEA") * (tblRCGRouteMasterCoProduct[RouteName]= "Sample Cleaning (2)") * (tblRCGRouteMasterCoProduct[LineNumber]= 10);0)

最佳答案

注意:在下面的公式中,不要忘记将逗号 , 更改为适合您所在区域的分号 ;

问题似乎是 MATCH 函数的第二个参数需要是一个数组。例如:

`=MATCH(1,1,0) --> #N/A

但是

=MATCH(1,{1},0) --> 1

因此,解决这个问题的一种方法是对单行数据主体范围使用不同的公式。

=IF(ROWS(tblRCGRouteMasterCoProduct[#Data])=1,IFERROR(1/(tblRCGRouteMasterCoProduct[RoutingCropGroupCode]="BEA") * (tblRCGRouteMasterCoProduct[RouteName]= "Sample Cleaning (2)") * (tblRCGRouteMasterCoProduct[LineNumber]= 10),NA()),MATCH(1,(tblRCGRouteMasterCoProduct[RoutingCropGroupCode]="BEA") * (tblRCGRouteMasterCoProduct[RouteName]= "Sample Cleaning (2)") * (tblRCGRouteMasterCoProduct[LineNumber]= 10),0))

另一种方法是确保即使是单个单元格也将是一个数组。正如 @JvdV 所指出的,这可以通过简化的方式来完成

=MATCH(1,INDEX(1,),0)

对于您的公式,这将是:

=MATCH(1,INDEX((tblRCGRouteMasterCoProduct[RoutingCropGroupCode]="BEA") * (tblRCGRouteMasterCoProduct[RouteName]= "Sample Cleaning (2)") * (tblRCGRouteMasterCoProduct[LineNumber]= 10),0),0)

关于arrays - 当源表只有一行时,使用 MATCH 的数组公式不会给出结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57554228/

相关文章:

vba - Excel VBA 将范围复制并粘贴到另一张工作表后清除范围

vba - 出现错误 "Object Variable or With block variable not set"

Excel 2016 - 从数组公式中删除 0

VBA 上的 Excel 公式错误

Excel:使用 [column_A 的唯一单元格,其中 column_B 值 = SomeValue] 填充下拉列表

Java:如何在文件中像字节数组一样写入短数组

arrays - 如何在不更改原始数组的情况下从数组中复制和删除?

javascript - 映射数组时如何计算两年之间的差异

excel - 如何更快地写这个?

arrays - 如果数组项等于名称,则获取数组项的索引