Lookup function to find first instance above current row

ddoublev

New Member
Joined
May 22, 2017
Messages
37
Hi,

I'm hoping someone may have an easy solution for this.

Below is a sample from a sheet I am working with. What I need to be able to do is look upwards from a row to find the FIRST instance of a value in order to calculate the number of days since the last reset.

Below is the formula I have been working with, however it only looks from most bottom row to top. What I need is to lookup from the row containing the formula and treat this row as the "bottom" row. (ie Formula in row 10 to look up from row 10)

=TODAY()-LOOKUP(2,1/([Stage 1 Startup Reset]=1),[Date])

Is this possible?

[TABLE="width: 421"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Date
[/TD]
[TD]Stage 1 Startup Reset
[/TD]
[TD]Stage 1 Days since reset
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]19/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]20/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]21/05/2017
[/TD]
[TD]1
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]22/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD]23/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD]24/05/2017
[/TD]
[TD]1[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]25/05/2017
[/TD]
[TD]0[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]9
[/TD]
[TD]26/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]27/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]11
[/TD]
[TD]28/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]29/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]13
[/TD]
[TD]30/05/2017
[/TD]
[TD]0[/TD]
[TD]-6
[/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD]31/05/2017
[/TD]
[TD]0
[/TD]
[TD]-6
[/TD]
[/TR]
</tbody>[/TABLE]

Thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I'm guessing a little here but perhaps:


Excel 2016 (Windows) 32 bit
ABC
1DateStage 1 Startup ResetStage 1 Days since reset
219/05/201700
320/05/201701
421/05/201712
522/05/201701
623/05/201702
724/05/201713
825/05/201701
926/05/201702
1027/05/201703
1128/05/201704
1229/05/201705
1330/05/201716
1431/05/201701
Sheet1
Cell Formulas
RangeFormula
C2=IFERROR($A2-LOOKUP(2,1/($B$1:$B1=1),$A$1:$A1),$A2-$A$2)


WBD
 
Upvote 0
Hi,
Thanks for your responses
I have succesfully worked the issue out with the following formula

=IF((A6-LOOKUP(2,1/(B$2:B6=1),A6))<0, NA(), (A6-LOOKUP(2,1/(B$2:B6=1),A6))) returns a value of 2.

Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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