Restrict to last occurrence using OFFSET

paulm88

New Member
Joined
Jun 13, 2017
Messages
15
Problem.JPG

I am trying to find how to return the workers pay the maximum number of weeks after their start date. As you can see in the example below, I have tried to OFFSET by the number of weeks (G2). However, this is returning the pay for worker Bob instead of the last instance of Paul (£25). I basically need to restrict the lookup to the worker no matter if the number of weeks exceeds the instances of column A.


Problem.JPG
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Could you paste a sample i can paste into excel rather than a picture?
 
Upvote 0
Worker
WeekPayWorkerStart WeekMax WeeksFinal Pay
Paul18/03/17£5Paul01/04/175{=OFFSET(INDEX(C:C,MATCH(E2&F2,A:A&B:B,0)),G2,0)}
Paul25/03/17£10
Paul01/04/17£15
Paul08/04/17£20
Paul15/04/17£25
Bob01/04/17£40
Bob08/04/17£50
Bob15/04/17£60
Bob22/04/17£70

<tbody>
</tbody>
 
Upvote 0
If im understanding correctly try this:

=LOOKUP(2,1/((A2:A100=E5)*(B2:B100<=(F5+G5*7))),C2:C100)
 
Upvote 0
Your formula works perfectly in theory and returns the value I would expect. However, the example I provided was poor! I was using OFFSET as it is not always the case that the dates will be every week, I've changed the example below.


WorkerWeekPayWorkerStart WeekMax paymentsFinal Pay
Paul01/03/17£5Paul06/09/175{=OFFSET(INDEX(C:C,MATCH(E2&F2,A:A&B:B,0)),G2,0)}
Paul07/06/17£10
Paul06/09/17£15
Paul22/11/17£20
Paul07/03/17£25
Bob13/04/17£40
Bob04/05/17£50
Bob25/05/17£60
Bob15/06/17£70

<tbody>
</tbody>
 
Last edited:
Upvote 0
The formula i provided doesnt care if you dont have dates every week. All it is doing is providing the last *date* that has the name paul and is before the 6/9/2017 + 5 weeks.

Edit. * Pay not date!
 
Last edited:
Upvote 0
Yeah, I can see that. Again, due to my poor example and the way I had been working it out, it wouldn't be weeks at all. So it would need to look for 5 rows down (changed to Max Payments rather than max weeks in the example), but stop at the last instance of Paul
 
Upvote 0
Could you try to explain in words what you want? The last instance of paul?
 
Upvote 0
Basically, 5 rows down from Paul 06/09/17...but stop at the last instance of Paul if this is less than 5 rows down. I've changed the examples below that hopefully makes it a bit clearer. on the left, the formula {=OFFSET(INDEX(C5:C21,MATCH(A2&B2,A5:A21&B5:B21,0)),C2,0)} works because there are enough instances of "Paul". However, if I change the Start Week as shown in the example on the right, it returns a value attributed to Bob.

Problem.V1.JPG
 
Upvote 0
This array formula appears to do the job. It must be entered CTRL-SHIFT-ENTER.

=IFERROR(INDEX(C5:C21,SMALL(IF((A5:A21=A2)*(B5:B21>=B2),(ROW(A5:A21)-ROW(A4))),C2)),LOOKUP(2,1/(A5:A21=A2),C5:C21))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,519
Messages
6,125,294
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top