下面是我所拥有的表的示例,我要做的是根据最后一次出现(不包括今天的日期)获取特定条件的值列中的值.
所以在下面的例子中,我想找到最后一次出现'A'的值,即12.
我认为这可以使用索引匹配来完成,但我无法理解它.
例如
Todays Date: 15/12/2013 ---------------------------------| |Date | Criteria | Value |--------------------------------| |12/11/2013 | A | 3 | |16/11/2013 | B | 6 | |27/11/2013 | C | 7 | |3/12/2013 | A | 12 | |5/12/2013 | B | 8 | |15/12/2013 | A | | ----------------------------------
编辑:我还想补充一点,这个公式将与上表不同.公式中的工作表参考也需要是动态的,它将从另一个单元格中绘制工作表名称.
小智 6
I would use this formula:
=index(C:C,max(arrayformula(match(filter(A:A,B:B="A",C:C<>""),A:A,0))),1)
This formula assumes that your data is in the columns A,B,C and for every "A" value in the Criteria column, the Date is different. (If that's not the case, then this formula won't work, see below.
Let's look the formula inside from outside:
Now, if you want this formula to work on another sheet, you should write, instead of for example:
=index(C:C,... => =index(Data!C:C,...
Assuming that your data is in your Data worksheet.
If you want to this sheet to be dynamic, it's a bit tricky. Let's assume, that you're getting the value of the sheet name from the G1 cell. Then you should write:
=index(indirect(concatenate(G1,"!C:C")),...
This is not so pretty as you should do this for every occasion when it occurs in that long formula (described earlier). Instead you can do some pre-work.
Let's write this to your H1 cell: =concatenate(G1,"!C:C") - If in the G1 cell the sheet name is "Data", then the H1 cell should contain: Data!C:C, similarly you can add to the
H2 cell: =concatenate(G1,"!A:A"), H3 cell: =concatenate(G1,"!B:B")
Now you can write (and that's the final answer for your question I think):
=index(indirect(H1),max(arrayformula(match(filter(indirect(H2),indirect(H3)="A",indirect(H1)<>""),indirect(H2),0))),1) - where H1,H2,H3 will reference to your Data sheet's columns.
I hope it helps.
| 归档时间: |
|
| 查看次数: |
7075 次 |
| 最近记录: |