Hey everyone, I’m stuck with a Google Sheets problem. My formula is giving me all the results instead of just the one I need.
Here’s what’s happening:
I’ve got a cell (C10) where I input a code like AC/12345. The sheet has data in this format: #CLIENTCODE#12345_DATE_BARCODE_Bread#67891_DATE_BARCODE_Wine#12345_DATE_BARCODE_Tea
When I put in AC/12345, I want to see:
Bread
Tea
But I’m getting:
Bread
Wine
Tea
Same thing happens with AC/67891. It should just show Wine, but it’s listing everything.
I’ve tried using a complex formula with REGEXEXTRACT, MAP, and FILTER, but it’s not working as expected. The formula is pretty long, so I won’t paste it here.
What I need is a way to make the formula return only the items linked to the specific code I input. Any ideas on how to fix this? Thanks!
I’ve encountered a similar issue before, and I found that using a combination of SPLIT() and ARRAYFORMULA() can be quite effective. Here’s what worked for me:
First, I’d split the data into separate rows using SPLIT(). Then, I’d use ARRAYFORMULA() with a REGEXEXTRACT() to pull out the client codes and item names. Finally, I’d apply a FILTER() to match the input code.
This assumes your data is in A1 and the input code is in C10. You might need to adjust the cell references.
The beauty of this approach is that it’s dynamic and should work with any number of items in your data string. Give it a shot and let me know if you need any tweaks!
hey soaringeagle, sounds like a tricky one! have u tried using SPLIT() to break up the string first? then maybe u could use FILTER() or QUERY() to grab just the parts matching ur input code. might be simpler than a complex regex. lemme know if u want me to throw together a quick example!