0
votes

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.

+--------------+------------+------------+-----------+
|     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.

So e.g. typing Susan Yellow and 08/26/16 should return $50 because it fell in this date range.

+-------------+------------+----------+
| 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 (e.g. 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. 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?

Thank you!

2

2 Answers

1
votes

Edit:

SottCraner's formula is much neat and simple.

=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))}

enter image description here

1
votes

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

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)))