简体   繁体   English

如何返回列与值匹配的数组

[英]How to return an array where a column matches a value

I am trying to create the column _Type_below which return the type value for a matching name AND a matching interval.我正在尝试创建列 _Type_below,它返回匹配名称和匹配间隔的类型值。 I know I can use VLOOKUP for individual names, but lets say I have thousands of names and I can specify an array for VLOOKUP for all of them.我知道我可以将 VLOOKUP 用于单个名称,但是假设我有数千个名称,并且我可以为所有名称指定一个 VLOOKUP 数组。 Cheers!!干杯!!

Name   position             _Type_             Name    Range_From      Range_To     Type
bob    0                      A                bob     0               30            A
bob    5                      A                bob     30              100           B
bob    10                     A                doug    0               40            C
bob    15                     A                doug    40              200           A
bob    20                     A
bob    30                     B
bob    40                     B
bob    80                     B
doug   0                      C
doug   20                     C
doug   40                     A
...       

If yu have the dynamic array formula you can use FILTER():如果你有动态数组公式,你可以使用 FILTER():

 =VLOOKUP(B2,FILTER(E:G,A2=D:D),3)

在此处输入图片说明


If not then your data must be sorted on D then E:如果不是,那么您的数据必须按 D 排序,然后按 E:

=VLOOKUP(B2,INDEX(E:E,MATCH(A2,D:D,0)):INDEX(G:G,MATCH(A2,D:D,0)+COUNTIF(D:D,A2)-1),3)

This should be relatively quick, but it requires the data sorted.这应该相对较快,但它需要对数据进行排序。

在此处输入图片说明

You can go super old fashioned and get the row using SumProduct() and pass that into Index() .您可以使用SumProduct()获得超级老式的行并将其传递给Index() It's not going to be speedy though.但这不会很快。

=INDEX($I$1:$I$5, SUMPRODUCT(($F$1:$F$5=A2)*($G$1:$G$5<=B2)*($H$1:$H$5>B2)*ROW($F$1:$F$5)), 1)

在此处输入图片说明

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

相关问题 Javascript从属性值匹配的对象数组返回数组 - Javascript return array from array of objects where property value matches C#返回数组的索引,其中值与任意字符串匹配 - C# return index of array where value matches an arbitrary string 如何在php中过滤键值匹配的数组 - how to filter array where a key's value matches in php 检查数组以查找字典值中的匹配项并返回键 - check array for matches in dictionary value and return key 将值添加到另一个数组中的值匹配的数组 - add value to array where value in another array matches 对数组值与另一个数组的键匹配的数组进行排序 - Sort array where array value matches another array's keys 选择列值匹配的第一行的值 - Select value of first row where column value matches 如何使用PostgreSQL查询给定列至少与给定数组中的所有值匹配的所有行? - How to query all rows where a given column matches at least all the values in a given array with PostgreSQL? 如何遍历列表数组,检查每个列表中的元素并与值进行比较,以及是否与值匹配,则返回键 - How to loop through an array of lists, check an element within each list and compare to a value and if it matches the value return the key 对象数组:仅返回属性匹配的对象(和子对象) - Array of objects: return only objects (and children) where attribute matches
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM