简体   繁体   English

具有两个条件的索引/匹配的查找率,包括一个日期范围

[英]Lookup rate with Index/Match with two criteria including one date range

In our Consulting business, we charge our clients according to a personal billing rate. 在我们的咨询业务中,我们根据个人计费率向客户收费。 These rates can change over time. 这些费率会随着时间而变化。 To be able to invoice customers for any service back in time, I want to build an Excel sheet that can facilitate this process. 为了能够及时向客户开具任何服务的发票,我想构建一个可以简化此过程的Excel工作表。

+--------------+------------+------------+-----------+
|     Name     |   Begin    |    End     |   Rate    |
+--------------+------------+------------+-----------+
| Paul Brown   | 2016-01-01 | 2016-01-31 |  $10.00   |
| Paul Brown   | 2016-02-01 | 2016-03-02 |  $20.00   |
| Paul Brown   | 2016-03-03 | 2016-04-02 |  $30.00   |
| Paul Brown   | 2016-04-03 | 2016-05-03 |  $40.00   |
| Anna Red     | 2016-02-15 | 2016-03-16 |  $100.00  |
| Anna Red     | 2016-03-17 | 2016-04-16 |  $127.00  |
| Anna Red     | 2016-04-17 | 2016-05-17 |  $145.00  |
| Martin Blue  | 2016-01-01 | 2016-04-30 |  $300.00  |
| Martin Blue  | 2016-05-01 | 2017-02-25 |  $400.00  |
| Susan Yellow | 2014-01-03 | 2014-12-29 |  $10.00   |
| Susan Yellow | 2014-12-30 | 2016-08-21 |  $30.00   |
| Susan Yellow | 2016-08-22 | 2016-09-21 |  $50.00   |
| Susan Yellow | 2016-09-22 | 2016-10-22 |  $190.00  |
| Susan Yellow | 2016-10-23 | 2016-11-22 |  $200.00  |
| Susan Yellow | 2016-11-23 | 2016-12-23 |  $210.00  |
+--------------+------------+------------+-----------+

In my Excel Sheet, I want to be able to enter the name of the person and any date and it should give me the correct billing rate. 在我的Excel工作表中,我希望能够输入此人的姓名和任何日期,并且应该给我正确的帐单汇率。

So eg typing Susan Yellow and 08/26/16 should return $50 because it fell in this date range. 因此,例如键入Susan Yellow和08/26/16应该返回$ 50,因为它在该日期范围内。

+-------------+------------+----------+
| Susan Yellow | 2016-08-26 |  $50.00  |
+-------------+------------+----------+

Dates before the first billing rate should default to the first known one, and ones with no current billing rate should default to the last known one (eg 01/02/2018). 第一个帐单汇率之前的日期应默认为第一个已知的日期,而没有当前帐单汇率的日期应默认为最后一个已知的日期(例如01/02/2018)。

Normally, I would just use an Index/Match formula but my issue is that I cannot combine criteria / build a helper column because that breaks the date range function. 通常,我只会使用Index / Match公式,但是我的问题是我无法合并条件/建立帮助列,因为这会破坏日期范围功能。 I could define custom table arrays instead, but I do not know how long each search area is because some consultants can have quite the history and others might be short. 我可以定义自定义表数组,但是我不知道每个搜索区域有多长时间,因为有些顾问的历史可能很长,而另一些顾问可能很短。

Anyone have a clue with what formula I can solve this in Excel/Google Sheets? 有人对我可以在Excel / Google表格中解决该问题的公式有一个线索吗?

Thank you! 谢谢!

Edit: 编辑:

SottCraner's formula is much neat and simple. SottCraner的公式非常简洁明了。

=SUMIFS(D:D,A:A,F3,B:B,"<=" & G3,C:C,">=" & G3)

This should work : {=SUM(IF(F3=$A$2:$A$16,IF((G3>=$B$2:$B$16)*(G3<=$C$2:$C$16),$D$2:$D$16,0),0))} 这应该起作用: {=SUM(IF(F3=$A$2:$A$16,IF((G3>=$B$2:$B$16)*(G3<=$C$2:$C$16),$D$2:$D$16,0),0))}

在此处输入图片说明

This will deal with the two situations where the date is not in ranges as required: 这将处理日期不在所需范围内的两种情况:

It is an array formula, so with required name in G1, and required date in H1, enter it in I1 with 它是一个数组公式,因此在G1中具有必填名称,在H1中具有必填日期,请在I1中输入

Ctrl-Shift-Enter Ctrl-Shift-Enter

=INDEX($D:$D,MAX(MAX(IF($A$2:$A$16=$G$1,IF($H$1>=$B$2:$B$16,ROW($C$2:$C$16)))),MATCH($G$1,$A:$A,0)))

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

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