前 N 次出现

Previous Nth occurrence

我在下面有一个 Excel 查询,我正在尝试从当前单元格的前 n 次出现中获取单元格的值。

基本上我是想获得上周同一天的价值, 从下面可以看出table,我想要上周同一天的分支机构销售。

通过搜索能够得到第 N 次出现但不能通过匹配和基于当前单元格的先前第 N 次出现。

上周同一天:

您可以使用 Index()Match() 来达到这个目的。

=IFERROR(INDEX(A:D, MATCH(B1-7,B:B),4),"")

将此公式放在 E1 中并向下拖动。显然,E 列中的前 7 行将是空白的,因为没有可匹配的内容(因此 IFERROR() 部分的原因。


回复,我没看到有两套标准。您可以使用公式数组来执行您需要的操作。

Warning: It's recommended that you do not include the entire column as shown in the below formula. This can decrease performance - especially when calculation is set to automatic. You should include a significant portion of the column that covers all of your data rather than the entire column (ie: instead of $A:$D, you could use $A1:$D500)

A1中输入以下公式,但先不要按回车键:

=IFERROR(INDEX($A:$D, MATCH(1,($B:$B=B1-7)*($C:$C=C1),0),4),"")

您的光标应该仍在编辑栏中闪烁。现在同时按下 Ctrl Shift Enter

如果操作正确,栏中的公式现在应该位于这些括号之间:{}.

最终结果应该是这样的:

{=IFERROR(INDEX($A:$D, MATCH(1,($B:$B=B1-7)*($C:$C=C1),0),4),"")}

You cannot "manually" input the brackets, you must do it with the key combo provided!!

现在,您可以根据需要向下拖动