简体   繁体   English

Excel 是否可以根据有多个匹配项的唯一键查找记录的数据,但根据条件仅返回一条记录?

[英]Can Excel Lookup data for a record based on a unique key where there are multiple matches, but return only 1 record based on a condition?

If I have a sheet with the following data, where the constants are always going to be the Load number and the Key...如果我有一张包含以下数据的表格,其中的常量总是加载号和密钥...

Load加载 Key钥匙 Size尺寸 Color颜色 Type类型
1 1 Tom汤姆 XL特大号
1 1 Jan S小号
2 2 Tom汤姆 XL特大号 Blue蓝色的
2 2 Jan S小号 Green绿色的
3 3 Tom汤姆 XL特大号 Red红色的 Pants裤子
3 3 Jan S小号 Green绿色的 Short短的

...is it possible, to have Excel lookup the key, and only bring back the size, color and type for the max(load) or highest load number? ...是否有可能让 Excel 查找密钥,并且只带回最大(负载)或最高负载数的大小、颜色和类型? So that it only shows the following?所以它只显示以下内容?

Key钥匙 Size尺寸 Color颜色 Type类型
Tom汤姆 XL特大号 Red红色的 Pants裤子
Jan S小号 Green绿色的 Short短的

The short answer is Yes, that can be done.简短的回答是肯定的,这是可以做到的。 The following formula is one way to approach it:以下公式是处理它的一种方法:

{=INDEX($E$1:$E$7,MATCH(A10&B10&C10,$B$1:$B$7&$C$1:$C$7&$D$1:$D$7,0))}

Notes:笔记:
a) The above is how the formula would look in cell D10, assuming the tables are as shown in the image below. a) 以上是公式在单元格 D10 中的样子,假设表格如下图所示。
b) This is an array formula and you don't enter the opening { or closing }. b) 这是一个数组公式,您不输入开始 { 或结束 }。 Rather, you 'commit' the formula using Ctrl, Shift and Enter.相反,您使用 Ctrl、Shift 和 Enter 来“提交”公式。

在此处输入图像描述

If I understood it right you want all the itens where load is 3 or max(Load), doesn't matter other parameters.如果我理解正确,您想要所有负载为 3 或最大(负载)的项目,其他参数无关紧要。 My answer suppose you have Excel 365, you only need to place it once in cell H2 of the exemple.我的回答假设您有 Excel 365,您只需在示例的单元格 H2 中放置一次。

=FILTER(Table[[Key]:[Type]];Table[Load]=MAX(Table[Load]);NA())

在此处输入图像描述

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

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