Lookup to Return Values based on Adjacent Column Search

Skiier89

New Member
Joined
Jun 14, 2022
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello -

First time posting but long time Excel user. Here is my question -

I have a data set on Sheet 1. The rows in column A contain names. The headings in column B, C, D, and so on contain dates.

Each name in column A may or may not have a value for a given date in the subsequent columns.

On a separate sheet (Sheet 2) within the workbook, I input one of dates from the table (say "4/15/2019") in a cell. How can I structure a lookup (v-, h-, x-, index/match) to return (or even spill) all names in column A of the table that have a non-blank value in the column with the corresponding date "4/15/2019"? If I change the date to another date, I would like the lookup to essentially filter out values in column A of the table to only those with a non-zero value in the column corresponding to the date entered.

For example, the formula on sheet 2 should only return/spill names: John Smith, Chris Cooper, Pam Johnson, Scott Peters, Anthony White.
When the date on sheet 2 is changed from "4/15/2019" to "12/31/2022", the formula should return Chris Cooper, Pam Johnson, Sarah Wilson, Scott Peters, and Janet Pearson.

I cannot use macros or VBA.

I've read a little about boolean logic in conjunction with the filter or sort functions, but can't wrap my head around it.

1655237042413.png
1655237068400.png
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Welcome to Mr. Excel,

Please try to use XL2BB to illustrate your data.

Here's one say: <code>=FILTER(Original!A2:A8,INDEX(Original!B2:L8,,MATCH(TRUE,B2=Original!B1:L1,0))<>"")</code>

Change the ranges accordingly.
 
Upvote 0
here's another option:

Code:
=FILTER(Original!A2:A8,0<>FILTER(Original!B2:L8,B2=Original!B1:L1))
 
Upvote 0
Thank you very much Kweaver! The nested filter function worked well. Another issue was also doing this within a defined table, which I have now abandoned as these functions are not supported with Excel tables..

Building on this - do you know how I could do the same thing, but if I wanted to show all names from Col A (the original sheet) that have a greater than 0 value in any dates that are less than or equal to the input date on sheet 2?

I've tried boolean logic for the second filter function - the "include" argument - by using the "<=" operators referencing the input date on sheet 2: =FILTER(Original!A2:A8,0<>FILTER(Original!B2:L8,B2<=Original!B1:L1))

However I keep getting a #calc or #value error. Do I need to nest yet another filter function?

For instance, if "12/31/2022" was the input date on sheet 2, all names from Col A would return since all names have a > 0 value for the dates equal to or preceding 12/31/2022.

Thanks again
 
Upvote 0
Not sure how elegant this is, but I think it works. I'll have to see if there's a shorter version.

=FILTER(Original!A2:A8,TRANSPOSE(0<>MMULT(--(Date!B2>=Original!B1:L1),--TRANSPOSE(Original!B2:L8>0))))
 
Upvote 0
Not sure how elegant this is, but I think it works. I'll have to see if there's a shorter version.

=FILTER(Original!A2:A8,TRANSPOSE(0<>MMULT(--(Date!B2>=Original!B1:L1),--TRANSPOSE(Original!B2:L8>0))))
Incredible. Absolutely incredible - thank you Kweaver!! :)

I am not familiar with MMULT but this works in my example workbook. Now I need to implement it into the actual workbook.

I would be remiss if I didn't ask you one more thing - how to make this filter work for in between two dates. For example - return all names that have a non-zero value for any dates between 12/31/17 and 12/31/18. Results would spill all names besides Sarah Wilson in the original example.
 
Upvote 0
MMULT means Matrix MULTiplication. It's a big more complicated mathematically than just simply product because it's multiplying rows by columns and then adding the results.

Between dates. Now you're pushing it...LOL...just kidding. Let me try that and see what i come up with.

How about this?

=FILTER(Original!A2:A8,TRANSPOSE(0<>MMULT(--(Date!B3>=Original!B1:L1)*(Date!B2<=Original!B1:L1),--TRANSPOSE(Original!B2:L8>0))))
 
Last edited:
Upvote 0
How about
Fluff.xlsm
ABCDEFGHIJKLMNOP
131/12/201730/06/201815/09/201802/01/201915/04/201931/12/201906/05/202001/10/201001/01/202115/09/202131/12/2022
2John25505535415215/09/2018John
3Chris6510213533166891522010/01/2020Chris
4Pam581394687Pam
5Sarah181920454446Sarah
6Scott222222222222Scott
7Ant2Janet
8Janet222222
9
Sheet4
Cell Formulas
RangeFormula
P2:P7P2=FILTER(A2:A8,MMULT((B1:L1>=O2)*(B1:L1<=O3)*(B2:L8>0),SEQUENCE(COLUMNS(B1:L1),,,0)))
Dynamic array formulas.


In future can you please post data, rather than an image.
 
Upvote 0
Incredible. Absolutely incredible - thank you Kweaver!! :)

I am not familiar with MMULT but this works in my example workbook. Now I need to implement it into the actual workbook.

I would be remiss if I didn't ask you one more thing - how to make this filter work for in between two dates. For example - return all names that have a non-zero value for any dates between 12/31/17 and 12/31/18. Results would spill all names besides Sarah Wilson in the original example.
I manipulated the array criteria in MMULT to the following and this has worked:

=FILTER(Original!$A$2:$A$8,TRANSPOSE(0<>MMULT(--(Original!$B$1:$L$1<=Date!$B$4)*(Original!$B$1:$L$1>=(Date!$B$4-365)),--TRANSPOSE(Original!$B$2:$L$8>0))))

Where Date!B4 is the input date. So the resulting array in any date less than the input date (usually going to be the year end 12/31/xx) but greater than the input date minus 1 year (i.e. -365).

When implementing this in the actual data set, the filtered results are including names that have a 0 or blank value for the date/year in question, but I can't determine why.
 
Upvote 0
Did you try the formula I suggested?
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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