简体   繁体   English

Excel查找2值

[英]Excel lookup 2 Values

I'm sorry if this is an obvious question, but I've been searching and can't seem to figure this out.. 很抱歉,如果这是一个明显的问题,但我一直在搜索,似乎无法弄清楚。

Cost TableCost Table
Employee    Date      Hours
2           03/16/16    8
2           03/17/16    8
2           03/20/16    8
3           03/21/16    8
3           03/22/16    8
5           03/23/16    10
6           03/24/16    4
6           03/28/16    5

Time Clock Table
Employee    Date      Hours
2           03/16/16    1
2           03/17/16    3
2           03/20/16    2
3           03/21/16    5
3           03/22/16    4
5           03/23/16    7
6           03/24/16    7
6           03/28/16    7

I just want to lookup on this table to see how many hours each employee worked on a certain date. 我只想在此表上查找以查看每个员工在特定日期工作多少小时。 They are cheating the system and we need to find out who's short. 他们在欺骗系统,我们需要找出谁矮。

You can use a formula like this 您可以使用这样的公式

=INDEX(TableCostTable[Hours],MATCH([@Employee]&[@Date],INDEX(TableCostTable[Employee]&TableCostTable[Date],0),0))

It concatenates the name and the date and uses Index/Match to look up the same combination and returns the hours. 它连接名称和日期,并使用“索引/匹配”查找相同的组合并返回小时。 The formula uses structured references with the column names and header names. 该公式使用具有列名和标题名的结构化引用。 It will also work if you use sheet names and cell references, but don't use it with whole columns, because that will be very slow. 如果您使用工作表名称和单元格引用,但也不要在整列中使用它,那么它也将起作用,因为这会非常慢。

在此处输入图片说明

在这种情况下,您需要使用SUMIFS而不是VLOOKUP

=sumifs(Paytable!C:C, Paytable!A:A,2,Paytable!B:B,date(2016,3,17))

You can solve this through a SUMIFS formula, such as: 您可以通过SUMIFS公式解决此问题,例如:

=SUMIFS(C:C, A:A, 2, B:B, "03/07/16")

What this is doing is summing all values in column C where column A is equal to 2 (for the employee) where column B is equal to 03/07/16. 这是对C列中的所有值求和,其中A列等于2(对于员工), B列等于03/07/16。

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

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