Query Array or Joined List

hi
in my app, I have array’s that have multiple text items in them, for example:
Array:
there is a cat
there is a dog
there is a bat

i want to query the array, or joined list and have it return a result, for example: “includes cat”
would return
“there is a cat”
this seems super basic and maybe i am just not understanding how to do it in glide. i don’t want to involve user inteface filtering, i need it in line with glide tables (not google sheets).

can someone point me in the right direction?
thank you!

What would you expect if there were multiple matches?
For example, if the query was includes there, what should the result be?

Hola @Clint_Nelms

Do you need anything like this?

The tricky part should be this…

image

image

Saludos!

1 Like

hi Darren,
thank you for the fast response. I am actually in a good situation in that the array items/list items are all unique. so i don’t have to worry about duplicates or multiple matches…

hi
thank you for the response. this is close to what i am after, however, i need to be able to seek a partial word. for example:
array contents:
this cat is red
this cat is blue
this cat is pink

the lookup should check for red, and the response needs to be “this cat is red”
so i want to filter the array by the word red and respond with any array item that has the word red in it.

if that generates multiple responses, i.e. “the cat is red” and “the dog is red” that is perfectly fine…

Ah, I see…

I think you are looking for an advanced filter method, take a look at this example and let me know your opinion: Multi Filters using Relations: a new way 💡

Bye

Would it be okay if generated results like Fred is blue?

1 Like

I’m not sure there will be a simple way to do this using standard computed columns, but it’s easy enough with a bit of Javascript. The following should give the results that you describe:

var arr = p1.split(',');
var re = new RegExp(p2,'g');
var matches = [];
arr.forEach(function (item){
  if (item.match(re)) {
    matches.push(item); 
  }
});
return matches.join(',');

4 Likes

wonderful. thank you Darren. i will give it a try and report back.

Darren, can’t thank you enough. that was awesome and worked perfectly.
I subbed out the * symbol in both the source joined list and the Java Script and I am getting the first match without issue. Should it be able to return more than one result? for example, if the Query was “this” can this approach respond with the “match multiple” style response and answer in a joined list?
thank you!!!

1 Like

Ah, I understand better @Clint_Nelms

The plan B could be this (a no-code solution :grinning:)

image

Saludos!

2 Likes

Great, and you’re welcome :slight_smile:

Not sure what you mean by this? That symbol isn’t used in the Javascript that I gave.

Yes.
If you look closely at the example I gave, you’ll see that’s exactly what it does :wink:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.