# Matching data using Query and filter

**URL:** <https://community.glideapps.com/t/matching-data-using-query-and-filter/81481>\
**Category:** Ask for Help\
**Created:** [April 22, 2025, 3:18pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481 "2025-04-22T15:18:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)\
**Post date:** [April 22, 2025, 3:18pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/1 "2025-04-22T15:18:56Z")

</div>

My Column data: [Strategy, Creative]

I want to use query to filter data that matches another row with the data: [User Experience, Creative] and another row: [Creative].

I should appear in the query to match this 2 rows but currently by using split text into array.  
I compare Array 1 contains Array 2 it will show if the data has the 2 text [Strategy, Creative] or only 1 text [Creative]

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 22, 2025, 11:45pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/2 "2025-04-22T23:45:02Z")

</div>

> [@Trustin](#):
>
> I want to use query to filter data that matches another row with the data: [User Experience, Creative] and another row: [Creative].

Can this just be a relation between the arrays or do you need to do more with the query?

---

<div class="post-metadata">

**Author:** ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)\
**Post date:** [April 23, 2025, 1:46am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/3 "2025-04-23T01:46:19Z")

</div>

Trying to find matches for users with multiples filters.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 23, 2025, 8:29am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/4 "2025-04-23T08:29:47Z")

</div>

But isn’t a relation doing what you want, or do you mean more filters outside of the “list” above?

---

<div class="post-metadata">

**Author:** ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)\
**Post date:** [April 23, 2025, 8:48am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/5 "2025-04-23T08:48:14Z")

</div>

Yeah using relation it match 1 array to another array. But I need to do another match based on another set of data. Definitely more than 3 filters. e.g Hobbies, Gender, Location.

My current set up using the query column, what i encounter was data set A [Apple, Orange] matching to data set B [Apple, Orange, Banana] the result is false.

but if data set A [Apple, Orange] matching to data set B [Orange, Apple] the result is true a match.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 23, 2025, 8:52am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/6 "2025-04-23T08:52:17Z")

</div>

You should definitely use the array for that, not the “is included” part.

I would do a relation and return the matching IDs for each filter.

Then feed all of them into a JS function perhaps, and find the ones that appear in all filter results.

---

<div class="post-metadata">

**Author:** ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)\
**Post date:** [April 24, 2025, 2:11pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/7 "2025-04-24T14:11:06Z")

</div>

I reference some related thread/topic.  
which has the following JS. But i need help with adjusting to my desired outcome.

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(‘,’);

Here a sample data which i want to filter A and B to find user that match them. I showed the result if its 1 data match but ideally i can have more data to filter to funnel down the match result.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/a/aaa03abf2c7d08f7ef08d866ad81504829a559c1.png)

---

<div class="post-metadata">

**Author:** ![Nicolas\_Joseph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nicolas_joseph/32/76105_2.png) [@Nicolas\_Joseph](https://community.glideapps.com/u/Nicolas_Joseph)\
**Post date:** [April 24, 2025, 9:01pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/8 "2025-04-24T21:01:29Z")

</div>

Hi @Trustin

According to your screenshot and if your data are structured like this, you can achieve the desired result by following these steps:

1. Create a “Split Text” column for each User Data column (this way, you’ll get an array of values)
2. Create a “JSON Template” column to store all the User Data for each row

```json
{
"username": $Username,
"numbers": [$Numbers],
"colors": [$Colors]
}

```

```
- Username → Username in another table
- Numbers → User Data A (split)
- Colors → User Data B (split)

```

1. Create a Lookup column of the previously created JSON Template column (you’ll store the JSON of each row this way)
2. Create a Joined List column of the Lookup (to get a comma separated list the JS column will be able to read)
3. Create a JavaScript column to filter your data and get the expected output

```js
let data = JSON.parse("[" + p1 + "]"); // to read and store the All joined JSON User Data

let filterNumbers = String(p2).split(","); // I had to force the String type because numbers are regarded as numbers... but it's not mandatory if you deal only with strings
let filterColors = p3.split(",");

let result = data
  .filter(user => 
    user.colors.some(color => filterColors.includes(color)) && // the .some means at least one element
    user.numbers.some(number => filterNumbers.includes(number))
  )
  .map(user => user.username) // you retrieve the username value
  .join(', '); // all matched usernames are joined

return result;

```

Here is my result with your sample data (the Gordon row is different because in my opinion, you should also get Gordon, he has a matching on “blue”):

 ![chrome_fhgVIl8JW5](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/4/844130cf9a959b85c83d24b82559c0a9ce3a37cd.png)

And the previous JS code let you also play with a second filter, as you can see (it’s an at least “one of the colours” AND at least “one of the numbers” filter type):

 ![chrome_Gcq7Dntot1](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/a/8abb7baa7999158adaa913a708be923a0b7e83ab.png)

If you have more filters to apply, just ajust the result variable by adding and ajusting another filter like that: "&& user.numbers.some(number =\> filterNumbers.includes(number))

Last observation: some steps I mentionned could have been done directly in JavaScript. However, I find it more easy to explain the logic this way. Feel free to improve it 😛

Hope it was what you wanted 👍

---

<div class="post-metadata">

**Author:** ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)\
**Post date:** [April 25, 2025, 5:30am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/9 "2025-04-25T05:30:29Z")

</div>

Thank you Nicolas! Yes it works!  
The javascript column we use, limits to P1 P2 and P3, which means it only accept up to 2 data to filter.  
I am wondering, let says i have 5 data(or even more) to filter and find the suitable match. Can I join list for all 5 data as a string. Then filter this 1 string. Will it work this way, or are there alternatives.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [April 25, 2025, 6:12am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/10 "2025-04-25T06:12:51Z")

</div>

> [@Trustin](#):
>
> I am wondering, let says i have 5 data(or even more) to filter and find the suitable match. Can I join list for all 5 data as a string. Then filter this 1 string. Will it work this way, or are there alternatives.

Yes, you can do that. So you could pass something like the following:

```auto
AAAAA||BBBBBB||CCCCC||CDDDDD||EEEEE

```

Then `p1.split('||')`, and you have 5 parameters 🙂

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 25, 2025, 9:17am UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/11 "2025-04-25T09:17:10Z")

</div>

Or do a JSON of all your inputs and then parse them out from a JSON string. Both will work.

---

<div class="post-metadata">

**Author:** ![Nicolas\_Joseph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nicolas_joseph/32/76105_2.png) [@Nicolas\_Joseph](https://community.glideapps.com/u/Nicolas_Joseph)\
**Post date:** [April 25, 2025, 8:35pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/12 "2025-04-25T20:35:23Z")

</div>

And if you need another option, in additon to the relevant ones already mentioned by @Darren_Murphy and @ThinhDinh, you can go for a Template column where you write your code and replace as many parameters as you want.

 ![chrome_2TsW4DaYpj](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/4/c4714c0dd0970d3e7db4b615560e8e9598228259.png)

Here, it’s just 5 “Text” columns, but you get this idea.

```js
let value1 = "p1";
let value2 = "p2";
let value3 = "p3";
let value4 = "p4";
let value5 = "p5";

let concat = value1 + " " + value2 + " " + value3 + " " + value4 + " " + value5

return concat;

```

And then… use this Template column as the source of your JS column.

 ![chrome_K1YVkwLvAz](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/4/3477d4062122f3187fb42caae3f683df292d99a0.png)

It’s not my idea of course, I’ve seen it in many Glide tutorials/posts 😌

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 25, 2025, 11:57pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/13 "2025-04-25T23:57:36Z")

</div>

That’s a nice idea. Thanks for sharing!

---

<div class="post-metadata">

**Author:** ![Trustin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/trustin/32/88217_2.png) [@Trustin](https://community.glideapps.com/u/Trustin)\
**Post date:** [April 27, 2025, 1:17pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/14 "2025-04-27T13:17:27Z")

</div>

Well, my approach for this was using template to collect all data.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/4/94605f391d0c2943f06d45780aad760d13ef9fca.png)

Pass it to Make JSON, and pass it as p1.

Its showing results but not sure if it is100% functionally returning the correct matching results.  
Will test some more.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [May 4, 2025, 1:18pm UTC](https://community.glideapps.com/t/matching-data-using-query-and-filter/81481/15 "2025-05-04T13:18:11Z")

</div>

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