Lookup value based on two column criteria

Dcap

New Member
Joined
May 22, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
i have been trying to solve the following issue:

i have a very long column of values (in this case there are only two values = FY23, FY24, with FY23 always coming before FY24) and another column values (all zeroes except one value >0 in an FY23 row and one value >0 in an FY24 row)



i want to create a lookup formula that searches the two columns to return the actual >0 value for both the FY23 and the FY24 rows



small example

ColA ColB

FY23 0

FY23 0

FY23 5

FY24 0

FY24 0

FY24 0

FY24 9



i have used IF/INDEX/MATCH with an else - and it returns the first value for FY23 (5), but for the second value it returns false

=IF(ColA="FY23",INDEX(ColB,MATCH(TRUE,ColB>0,0)),"Pending") will return 5

=IF(ColA="FY24",INDEX(ColB,MATCH(TRUE,ColB>0,0)),"Pending") will return Pending instead of 9

Note: both use Cntl-Shift-Enter



i see what it is doing - it is counting the match down to the 5 (giving it row 3) and then it sees FY23 in ColA - hence the return of Pending
i cant figure out how to get it to go to FY24

i have tried using VLOOKUP but have gotten nowhere
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try:
Book1
ABCDE
1FY23059
2FY230
3FY235
4FY240
5FY240
6FY240
7FY249
Sheet6
Cell Formulas
RangeFormula
D1:E1D1=XLOOKUP(TRUE,B1:B7>0,B1:B7,,,{1,-1})
Dynamic array formulas.
 
Upvote 0
Try:
Book1
ABCDE
1FY23059
2FY230
3FY235
4FY240
5FY240
6FY240
7FY249
Sheet6
Cell Formulas
RangeFormula
D1:E1D1=XLOOKUP(TRUE,B1:B7>0,B1:B7,,,{1,-1})
Dynamic array formulas.
that worked - thanks so much
i dont quite understand what the formula is doing but it worked -
much appreciated
 
Upvote 0
You're welcome. The formula checks each cell is >0, then looks for the first and last TRUE. Return the values.
 
Upvote 0

Forum statistics

Threads
1,217,365
Messages
6,136,124
Members
449,993
Latest member
Sphere2215

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