简体   繁体   English

Excel公式:具有多个条件的数组中的返回值

[英]Excel Formula: Return value from array with multiple criteria

Suppose the following series: 假设以下系列: 在此处输入图片说明

I am trying to find the latest non 1 value that precedes the latest 1. 我试图找到在最新1之前的最新非1值。

In this case it should return 3 and not 4. 在这种情况下,它应该返回3而不是4。

1 being the minimum value I have tried to use MATCH(MIN(range),range,0) and add 1 to get the value I needed, but the minimum function gets stuck on the first occurrence of the minimum. 1是最小值,我尝试使用MATCH(MIN(range),range,0)并加1以获得所需的值,但是最小值函数在第一次出现最小值时被卡住。

Try 尝试

=INDEX(B1:P1,1,MATCH(1,(OFFSET(B1:P1,,-1)=1)*(B1:P1>1),0))

Where B1:P1 is your data range. 其中B1:P1是您的数据范围。 Of course it is an array formula (SHIFT+ENTER). 当然,这是一个数组公式(SHIFT + ENTER)。

Hope that helps. 希望能有所帮助。

I can't see a short and snappy answer to this but here is one suggestion assuming the data starts in column A 我看不到对此的简短回答,但这是一个建议,假设数据从A列开始

=INDEX(2:2,AGGREGATE(15,6,COLUMN(INDEX(2:2,MATCH(1,2:2,0)):INDEX(2:2,MATCH(999,2:2)))/(INDEX(2:2,MATCH(1,2:2,0)):INDEX(2:2,MATCH(999,2:2))>1),1))

If the range didn't start in column A, you would have to subtract the number of the column before the first column of the range from the column number returned by the AGGREGATE to get the correct index value relative to the start of the array eg for B2:Z2 如果范围不是从A列开始,则必须从AGGREGATE返回的列号中减去范围的第一列之前的列号,以获得相对于数组开头的正确索引值,例如对于B2:Z2

=INDEX(B2:Z2,AGGREGATE(15,6,COLUMN(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):INDEX(B2:Z2,MATCH(999,B2:Z2)))/(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):INDEX(B2:Z2,MATCH(999,B2:Z2))>1),1)-COLUMN(A:A))

To be honest it wouldn't be worth using a MATCH to find the last number in the range unless the number of cells in the range was very large, so the formula for B2:Z2 would just be 老实说,除非在该范围内的单元格数量非常大,否则使用MATCH查找范围中的最后一个数字是不值得的,因此B2:Z2的公式为

=INDEX(B2:Z2,AGGREGATE(15,6,COLUMN(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):Z2)/(INDEX(B2:Z2,MATCH(1,B2:Z2,0)):Z2>1),1)-COLUMN(A:A))

Formula starting column A 公式从A列开始

在此处输入图片说明

Formula starting at column B 从B列开始的公式

在此处输入图片说明

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

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