简体   繁体   中英

Get Array in order based on criteria using excel formula

Hi I've been struggling how to get the array in order based on criteria, for example here in the table below I would like to get the array of the values in Column B for product "B" in Column A. The output should be {2.03;2.09;1.84} in order.

在此处输入图片说明

Currently here's the available formulas I've found but does not address the ouput I would like to achieve.

=IF(A2:A7="B",B2:B7,"")

The result is {"";2.03;"",2.09;"";1.84}

Another formula is

=SMALL(IF(A2:A7="B",B2:B7),ROW(INDIRECT("1:"&COUNTIF(A2:A7,"B"))))

The result is in ascending {1.84;2.03;2.09}

What I wanted to achieve is to return an array based on order as per occurence, as per example should be {2.03;2.09;1.84}.

Anyone knows the formula for this? Thanks in advance for the help.

If one has the new Dynamic Array Formula FILTER, use:

=FILTER(B2:B7,A2:A7="B")

Put that in the first cell and Excel will spill the results automatically

If not then use INDEX/AGGREGATE:

=INDEX(B:B,N(IF({1},AGGREGATE(15,7,ROW($A$2:$A$7)/($A$2:$A$7="B"),ROW($ZZ$1:INDEX($ZZ:$ZZ,COUNTIF(A2:A7,"B")))))))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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