# I want to expand data that is structured like X-X where the X's are variable, this will be used for filtering

**URL:** <https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490>\
**Category:** Ask for Help\
**Created:** [September 19, 2024, 1:53pm UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490 "2024-09-19T13:53:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 19, 2024, 1:53pm UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/1 "2024-09-19T13:53:21Z")

</div>

Hey everyone - I hope you’re all well 🙂

I’m trying to create a filter where the user can filter by the range of players suitable for boardgames. The current dataset I receive is set like this;

3-8  
5-6  
2-10  
1-99

What I want to be able to filter by is any of the numbers between the 2 ranges so that when a user searches for a number they are included within the filter results.

e.g 2-10 would be applicable for any filters where 2,3,4,5,6,7,8,9,10 are selected.

I hope that’s enough information.

---

<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:** [September 19, 2024, 2:03pm UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/2 "2024-09-19T14:03:42Z")

</div>

You could use a JavaScript column:

```auto
const min = Number(p1.split('-')[0]);
const max = Number(p1.split('-')[1]);
if (p2>=min && p2 <= max) {
  return true;
}

```

 ![CleanShot 2024-09-19 at 22.02.46@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/d/0d9d7f5d80fb1b573aed5d734b334d76ada474e3.png)

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 19, 2024, 9:06pm UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/3 "2024-09-19T21:06:58Z")

</div>

Does this work for In-App filtering?

---

<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:** [September 19, 2024, 11:45pm UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/4 "2024-09-19T23:45:44Z")

</div>

Yes, you could add the JavaScript column as an in-app filter.

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 20, 2024, 7:23am UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/5 "2024-09-20T07:23:34Z")

</div>

Ah ok cool! I’m struggling to use the data for filtering. I can’t seem to get it to work, Are you able to show me how it would be implemented?

---

<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:** [September 20, 2024, 7:32am UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/6 "2024-09-20T07:32:11Z")

</div>

Well, the thing is, I’m not sure that it makes much sense to use it with an in-app filter. And in fact the only way to do that would be to combine the in-app filter with a custom filter. This is because in order to process all rows with the JavaScript column you would first need to capture some user input (a number, for example) in a user specific column, and then apply that to all rows and feed it into the JavaScript column.

Let me ask you a question: how do you envisage the ideal user experience? What would they see, and how would they interact with it?

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 20, 2024, 7:34am UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/7 "2024-09-20T07:34:19Z")

</div>

It was basically so the user can select the number of recommended players for a board game and filter the collection.

The issue is that I only have data stored as player count : 2-7 which doesn’t include 3,4,5,6 within that data.

---

<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:** [September 20, 2024, 7:35am UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/8 "2024-09-20T07:35:14Z")

</div>

So you would want them to select a number from a list?  
Or just enter a number?

---

<div class="post-metadata">

**Author:** ![Mark\_Bailey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_bailey/32/15001_2.png) [@Mark\_Bailey](https://community.glideapps.com/u/Mark_Bailey)\
**Post date:** [September 20, 2024, 7:38am UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/9 "2024-09-20T07:38:11Z")

</div>

I’m using the in-app filter component for the other filter options so I’d assume it would be using a similar pattern (selecting from list) I’m not sure if it can include text entry in that way.

---

<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:** [September 20, 2024, 7:51am UTC](https://community.glideapps.com/t/i-want-to-expand-data-that-is-structured-like-x-x-where-the-xs-are-variable-this-will-be-used-for-filtering/76490/10 "2024-09-20T07:51:35Z")

</div>

Alright, try this:

- Use a modified version of the JavaScript that I gave you as follows:

```auto
const min = Number(p1.split('-')[0]);
const max = Number(p1.split('-')[1]);
const arr = [];
for (let i = min; i <= max; i++) {
  arr.push(i);
}
return arr.join(',');

```

- You should pass the Player Ranges column as `p1`. The column will return a list of all numbers in the range.
- Add a Split Text column, and target it at the JavaScript column. This will create an array from the Joined List.
- Use the Split Text column as an In-App filter
