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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,224,739
Messages
6,180,676
Members
452,993
Latest member
FDARYABEE

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