SEARCH problem?

sharshra

Active Member
Joined
Mar 20, 2013
Messages
404
Office Version
  1. 365
This has reference to one of my post (Filter problem) which was solved. However, I´m facing an issue. I think the formula searches for first digit only. If there is more than 1 digit number, it will search & return true if one of the digits match the search text. I suspect SEARCH is not working properly. I´m sure I must have made silly mistake but couldn´t figure out. Can the experts in this forum help please?

Consider the following example. Table 1 has t id & used r id. Table 2 has r id & t ref. I have to find out which item under r id in table 2 is called under used r id in table 1.
The formula works well to some extent. But when a number is repeated in any of the digits, it is returning incorrect result.
Let´s look into few results -
- rq id 9 is not used in table 1, but formula returns 3, 8 since it has 89. Formula detects 9 in 89 & returns true.
- rq id 1 is used only in t id 2 in table 1, but formula returns 1, 2, 6 since 1 & 6 has 11 & returns true.

Table 1 -
Book1
BCD
2t iddescused r id
31fdsfds11
42fdfds1,11,2
53er89
64ere32
75vvafd3,5
86wqw4173,32,11
97yiy85,55
10865jg89
119ere2
12103y4y3
Sheet1


Table 2 -
Book1
BCD
2rq idrqt ref
31vcv1, 2, 6
41141d1, 2, 6
52kukyu2, 4, 6, 9
632yutry4, 6
734fv5, 6, 10
873urtr6
95c<c5, 7
1055nbmb7
119eqq3, 8
1289796k3, 8
Sheet 2
Cell Formulas
RangeFormula
D3:D12D3=LET( x,Table2[t id], y,Table2[used r id], IFERROR(TEXTJOIN(", ",,(FILTER(x,ISNUMBER(SEARCH([@[rq id]]&",",y & ","))))),"no value"))


Expected result - Incorrect results are highlighted in orange cell color.
Book1
GH
1expected values in t ref
2rq idt ref
312
4111,2,6
522,9
6324,6
735,10
8736
955,7
10557
119no value
12893,8
Sheet 2
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Looks like you link to the wrong thread, but try
Excel Formula:
=LET(x,Table2[t id],y,Table2[used r id],IFERROR(TEXTJOIN(", ",,(FILTER(x,ISNUMBER(SEARCH(","&[@[rq id]]&",",","&y & ","))))),"no value"))
 
Upvote 0
That´s great. Thanks a lot, @Fluff. It almost solved my problem. But one more hurdle :giggle:
When there is a gap between numbers in used r id field in Table2, it does not return correct values. How can this be fixed?

For example, consider the following tables.
Table 1 - Note that t id 7 has used r id of 5, 55.
search problem.xlsx
BCD
2t iddescused r id
31fdsfds11
42fdfds1,11,2
53er89
64ere2,3
75vvafd2,3
86wqw4173,32,11
97yiy85, 55
10865jg89
119ere2,3
12103y4y3
Sheet1


Table 2 - Note that 55 is not returned since there is a gap between 5 & 55 in table 1 used r id field. if I remove the space between 5 & 55, it works correctly.
search problem.xlsx
BCD
2rq idrqt ref
31vcv2
41141d1, 2, 6
52kukyu2, 4, 5, 9
632yutry6
734fv4, 5, 9, 10
873urtr6
95c<c7
1055nbmbno value
119eqqno value
1289796k3, 8
Sheet 2
Cell Formulas
RangeFormula
D3:D12D3=LET(x,Table2[t id], y,Table2[used r id], IFERROR(TEXTJOIN(", ",,(FILTER(x,ISNUMBER(SEARCH(","&[@[rq id]]&",",","&y & ","))))),"no value"))
 
Upvote 0
Hello Experts, any solution to this problem? We are almost there except one small glitch.
 
Upvote 0
Try:
Excel Formula:
=LET(
x,Table2[t id],
y,SUBSTITUTE(Table2[used r id],", ",","),
TEXTJOIN(", ",,(FILTER(x,ISNUMBER(SEARCH(","&[@[rq id]]&",",","&y & ",")),"no value"))))
 
Upvote 0
Thanks, @Cubist. It works when there is one space (y) It is good for now.

If there are more than one spaces, it does not work :unsure:. How can the formula be made more robust to handle any number of spaces?
 
Upvote 0
Remove all the spaces.
Excel Formula:
=LET(
x,Table2[t id],
y,SUBSTITUTE(Table2[used r id]," ",""),
TEXTJOIN(", ",,(FILTER(x,ISNUMBER(SEARCH(","&[@[rq id]]&",",","&y & ",")),"no value"))))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,116
Members
453,021
Latest member
Justyna P

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