Filter problem

sharshra

Active Member
Joined
Mar 20, 2013
Messages
352
Office Version
  1. 365
When there are multiple items in the cell referred by include parameter, how to get the correct result for the parameter passed?

For example, consider the table below. When I filter for rq 1, it returns d2 only since it has only rq 1. There are other rows which has rq 1 along with other values. I would like the formula to return d2, d4 (d2 has rq 1 only & d4 has rq 7, rq 1). Can the experts in this forum suggest please?

requirement mapping.xlsx
F
3d2
table 2
Cell Formulas
RangeFormula
F3F3=CHOOSECOLS(FILTER(B3:C17,C3:C17="rq 1"),1)


requirement mapping.xlsx
BC
2drq ref
3d1rq 5
4d2rq 1
5d3rq 10
6d4rq 7, rq 1
7d5rq 6
8d6rq 3
9d7rq 9, rq 10
10d8rq 2
11d9rq 3
12d10rq 2
13d11rq 4, rq 9
14d12rq 8
15d13rq 4
16d14rq 5
17d15rq 10, rq 6
table 2
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
A bit complicated but might work:

Excel Formula:
=LET(
search,"rq 1",
rqref,C3:C17,
d,B3:B17,
array,BYROW(--(search=DROP(REDUCE("",rqref,LAMBDA(a,b,IFERROR(VSTACK(a,TEXTSPLIT(b,", ")),FALSE))),1)),LAMBDA(a,SUM(a))),
FILTER(d,array>0))
 
Upvote 0
Book1
BCDEF
2drq ref
3d1rq 5d2
4d2rq 1d4
5d3rq 10
6d4rq 7, rq 1
7d5rq 6
8d6rq 3
9d7rq 9, rq 10
10d8rq 2
11d9rq 3
12d10rq 2
13d11rq 4, rq 9
14d12rq 8
15d13rq 4
16d14rq 5
17d15rq 10, rq 6
Sheet10
Cell Formulas
RangeFormula
F3:F4F3=LET( x,C3:C17,y,B3:B17, c,LEN(x) - LEN(SUBSTITUTE(x, ",", ""))+1, a,TOCOL(IFS(c>=SEQUENCE(1,MAX(c)),y),2), b,DROP(REDUCE("",x,LAMBDA(a,b,VSTACK(a,TEXTSPLIT(b,,", ")))),1), FILTER(a,b="rq 1") )
Dynamic array formulas.
 
Upvote 0
Try this:

Book1
BCDE
1drq ref
2d1rq 5d2
3d2rq 1d4
4d3rq 10
5d4rq 7, rq 1
6d5rq 6
7d6rq 3
8d7rq 9, rq 10
9d8rq 2
10d9rq 3
11d10rq 2
12d11rq 4, rq 9
13d12rq 8
14d13rq 4
15d14rq 5
16d15rq 10, rq 6
Sheet1
Cell Formulas
RangeFormula
E2:E3E2=FILTER(B2:B16,ISNUMBER(SEARCH("rq 1,",C2:C16&",")),"")
Dynamic array formulas.
 
Upvote 0
@Phuoc, thanks for the smart formula. That works (y) We are very close. I just need one more thing to be done. Now the formula results in an output in 2 rows - d2 & d4 in 2 rows. Instead, I need an output in a single cell. For example, output should be d2, d4.
 
Upvote 0
You can do that using textjoin like
Excel Formula:
=TEXTJOIN(", ",,FILTER(B2:B16,ISNUMBER(SEARCH("rq 1,",C2:C16&",")),""))
 
Upvote 0
Solution
Perfect, @Fluff (y). As always, experts in this forum are always there when you need something in Excel :love:. Thanks a ton :)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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