# \[Solved\] Filtering data return only one results

**URL:** <https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257>\
**Category:** Questions about Thunkable X\
**Created:** [December 17, 2023, 11:35am UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257 "2023-12-17T11:35:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![minamaestro2023kg](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@minamaestro2023kg](https://community.thunkable.com/u/minamaestro2023kg)\
**Post date:** [December 17, 2023, 11:35am UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/1 "2023-12-17T11:35:20Z")

</div>

HI EveryOne  
I’m using the following blocks to filter data but it returns invalid results

 ![Screenshot 2023-12-17 133507](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/23b8b976e6670404ee5d5b3da39fdf62fe851e73.png)  
when selectin the date 5-1-2024 it returns results from 5-12-2023  
In Addition there is another variant of the block where it returns only the first result where actually there are many results that meet that criteria  
 ![Screenshot 2023-12-17 134352](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/e/feec63b46439c0265becef950e0f94dc1e46e7f8.png)  
I both cases I’m filtering data from on datasource to another to populate a data viewer list.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 17, 2023, 5:22pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/2 "2023-12-17T17:22:33Z")

</div>

Your problem is the [gear] list block. Remove it. It’s almost always a bad idea to use it unless you’re initializing a list.

With it included, you’re creating a list of a list because the list of values block is _already_ a list. This may be why you’re only getting one result. Your loop only has one item (a list of a list instead of a list of items).

An example is if your spreadsheet column contained:

apple  
orange  
lemon

Then the list of values block would create a list like this with three items:

{apple,orange,lemon}

But by adding the [gear] list block in front of that, it creates a list like this with only one item:

{{apple,orange,lemon}}

---

<div class="post-metadata">

**Author:** ![minamaestro2023kg](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@minamaestro2023kg](https://community.thunkable.com/u/minamaestro2023kg)\
**Post date:** [December 17, 2023, 5:40pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/3 "2023-12-17T17:40:26Z")

</div>

@tatiang  
Yes this did the job.

---

<div class="post-metadata">

**Author:** ![minamaestro2023kg](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@minamaestro2023kg](https://community.thunkable.com/u/minamaestro2023kg)\
**Post date:** [December 17, 2023, 5:56pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/4 "2023-12-17T17:56:12Z")

</div>

@tatiang  
After removing the fear list block ,Now if there is a matching result this block returns all the items in the table

 ![Screenshot 2023-12-17 134352](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/e/feec63b46439c0265becef950e0f94dc1e46e7f8.png)  
like this screenshot here  
 ![Screenshot 2023-12-17 195712](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/3/c358920785b633f149909c5c1a24456faeaf2225.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 17, 2023, 6:30pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/5 "2023-12-17T18:30:09Z")

</div>

You may need to refresh the data viewer after your loop.

Can you post a link to your project?

**Edit:** actually, I see your mistake. For every iteration of the loop, you’re checking to see if the _entire list_ contains the search term. Instead, you need to check if the item **i** equals the search term.

---

<div class="post-metadata">

**Author:** ![minamaestro2023kg](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@minamaestro2023kg](https://community.thunkable.com/u/minamaestro2023kg)\
**Post date:** [December 17, 2023, 10:56pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/6 "2023-12-17T22:56:32Z")

</div>

@tatiang  
I tried this one but the problem still exists

 ![Screenshot 2023-12-18 005513](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/e/9e0b40d283e3c36245ffb4cd2f9598e09a7519ae.png)  
 ![Screenshot 2023-12-18 005608](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/5/95149206b2d7721ff45fb4f68a0ce10756aaffdc.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 17, 2023, 11:40pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/7 "2023-12-17T23:40:04Z")

</div>

Sorry, I was a little took quick in my explanation. You’re using **i** as the loop counter. So it doesn’t make sense to compare that to your search term (1=“Cola”?, 2=“Cola”?). You have to use the `for each j in list` block and compare j (the list item) to the search term.

---

<div class="post-metadata">

**Author:** ![minamaestro2023kg](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@minamaestro2023kg](https://community.thunkable.com/u/minamaestro2023kg)\
**Post date:** [December 18, 2023, 9:25am UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/8 "2023-12-18T09:25:15Z")

</div>

@tatiang  
I tried this one

 ![Screenshot 2023-12-18 112303](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/e/fecaa19181727b46aa7793c7dd6fe1888120c6ad.png)  
I think this one works But it return empty rows.  
 ![Screenshot 2023-12-18 112405](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/d/0de8277a94449b4744f1c1b65414f8d3f8a2a0c3.png)

---

<div class="post-metadata">

**Author:** ![minamaestro2023kg](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@minamaestro2023kg](https://community.thunkable.com/u/minamaestro2023kg)\
**Post date:** [December 18, 2023, 9:30am UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/9 "2023-12-18T09:30:23Z")

</div>

The Arrows appear only if there is a match, but in case there is no match it didn’t appear.

---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [December 18, 2023, 6:47pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/10 "2023-12-18T18:47:13Z")

</div>



---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 18, 2023, 7:58pm UTC](https://community.thunkable.com/t/solved-filtering-data-return-only-one-results/2753257/11 "2023-12-18T19:58:37Z")

</div>

The row id cannot be the value in **j**. So here’s the slightly tricky part: if you count with a loop variable that is an integer such as your earlier example with **i** , you can’t use that to search for a search terms. But if you use a string as in your example with **j** then that is not a valid row id.

My suggestion is to create a variable called app variable Row and set it to 0 before the `for each item j in list` loop and then within the loop, change its value by 1 before the `if` block. Then, if j=app variable Selected Date, you use app variable Row as the row id in your `create row` block.
