# Filter local Table

**URL:** <https://community.thunkable.com/t/filter-local-table/1260996>\
**Category:** Questions about Thunkable X\
**Created:** [May 3, 2021, 6:58pm UTC](https://community.thunkable.com/t/filter-local-table/1260996 "2021-05-03T18:58:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 6:58pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/1 "2021-05-03T18:58:51Z")

</div>

Here am trying to create location guide tour, the locations will be shown on a map and the user only need to click on the marker and he will get the required information.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/e/8e8e3d2f948fc72a25bc73adbd28ee5426b55046.jpeg)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/5/8536c8263c3fd3c2d94f5a987f31ddb1403e9034.png)

to do that I connected to Google Sheets , then i created function to store the values to a local table

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/f/bf1c4c384c8c0cfdab909856b6a1a44323d30453.png)

The idea was to display the location information (lati, longi ,titles, desc), it is working fine,  
but when I clicked on a map makers i need to to display the specific information about that locations. to do that i created the following:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/2/b255955320f597a0f9277372192ce45f00713870.png)

To be honest i don’t know how to filter the local table which contains the whole information and get only the specific location info

---

<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:** [May 3, 2021, 7:06pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/2 "2021-05-03T19:06:36Z")

</div>

It looks like you’ve done most of the work here. The one problem I see right away is that you are getting the value from row id “id”. That needs to be an actual row id from your database. Try putting tbIndex in that row value and see if it works.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 7:14pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/3 "2021-05-03T19:14:25Z")

</div>

yes… you are right… I stuck with that, I don’t know what is the next step

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 7:15pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/4 "2021-05-03T19:15:13Z")

</div>

I don’t know how to handle local table…when it contains the data, i couldn’t find any way to filter it

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 7:20pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/5 "2021-05-03T19:20:39Z")

</div>

Your `onMarkerPress` will not work because there is no `row id` and none of your variables has the `row id` for that specific row saved.

One way is to use the tbIndex but you will need `in list [list of values ` and use the `ID` column for that table.

Another issue is the way you populate the local table. You are retrieving all rows for each column to create every matching record. It would work now but when you have 200 rows or more it will be very slow.

This is just an opinion.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 7:24pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/6 "2021-05-03T19:24:16Z")

</div>

Thank you muneer for your valuable comments …Sir what is your suggestions…is there any guide lines to follow… please am still new. I was thinking this is the best way

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 8:49pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/7 "2021-05-03T20:49:06Z")

</div>

Instead of querying the database with every record, Retrieve all the wanted columns all in lists and then loop through the list.

For example, If I want my local table to get the item name and item price from my sheet, I will have 2 lists  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/0/40df90cfeba03041e01367c897f2f9490a273a8e.png)

And in my code will get the required columns before going into the loop

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/3/33e4ed2eae8fb4099ef50cf0676a2f662fc62faf.png)

My loop will be from 1 to number of records in my table and will create a row in my local table from the lists already created and will not need to use [list of values …] every time.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/2/c251ea3c04bd20b85d5519dfa9f7c3c76fe10006.png)

You might not notice a difference now but when you have hundreds of records this approach is much faster.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 8:56pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/8 "2021-05-03T20:56:02Z")

</div>

Thank you muneer, I will change it right now… but am still buzzled by how to filter the table once I filled it with records… how to search for a particular value…it seems very difficult mission. please if you have time could you help …

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 8:58pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/9 "2021-05-03T20:58:42Z")

</div>

see my [Shopping List Project](https://x.thunkable.com/projectPage/5fb9fb1dbfeb240011084d78) and if you need help or more explanation then I can explain the part not clear to you.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 9:12pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/10 "2021-05-03T21:12:22Z")

</div>

Excellent Example. Sir…a lot of tricks and workout coding. I really learned a lot…from your example… and i will re-write my application. Based on the codes in your example…

please one thing … regarding the table there is no way to query it directly, because the values already stored there.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 9:15pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/11 "2021-05-03T21:15:39Z")

</div>

I didn’t understand your question.  
Can you elaborate?

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 9:20pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/12 "2021-05-03T21:20:55Z")

</div>

Sorry… for that… ok… what am trying to say is that, in my case I created a local table then I filled with data from my google sheets. once the data inside that table. my question… is there any way to query it directly.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/6/c68fb58f9337e99a7c9c4a3d09d0da3b97ed6c10.png)

Here I create a loop and I filled ListOfLoc, with the data, can i query those data later on…

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 9:24pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/13 "2021-05-03T21:24:57Z")

</div>

Yes, you can query the data while still in your sheet and you can as well query it after populating the local table. It is your choice.

If you see my **Shopping Example** , I was querying the main table and only insert in the local table the records I select from the query.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 9:32pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/14 "2021-05-03T21:32:46Z")

</div>

yes …

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/9/d970097b80ff2a78186979dace00deca6a23a5b7.png)

what puzzled me is the SelectedCategory…I was traying to compare it with my data, in my case It was latitudes…the user will click on the map markers then he will get the latitude for that location…then my problem started here…how to search the main table …from your example above you got a list of row ids, then we are going to select a row in the table and compare cat code with the one which was selected from the data viewer list (first step) … if we got the correct result the data will be transferred to another table “SelectedCat”, then we can display that data to the user…Is that correct…  
Excuse me… muneer for all these details…

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 9:54pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/15 "2021-05-03T21:54:53Z")

</div>

> [@nmtabooks](#):
>
> from your example above you got a list of row ids, then we are going to select a row in the table and compare cat code with the one which was selected from the data viewer list (first step) … if we got the correct result the data will be transferred to another table “SelectedCat”, then we can display that data to the user…Is that correct…  
> Excuse me… muneer for all these details…

Yes this is correct.

This is why I use a list of IDs because you can get any row from the table by ID

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/7/8703c076cd6c327b6e8dff65959e9c25b730a2bc.png)  
The get value block needs ID this is why I use a list of IDs in the table.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 9:57pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/16 "2021-05-03T21:57:56Z")

</div>

Yes… Your are right… am now working on your solution and re-write the codes in my application… thank you muneer it was a great help…and a way of think…

Thank you 👏 👏 👏 👏

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 10:04pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/17 "2021-05-03T22:04:47Z")

</div>

Thank you Sir… it works…

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/b/5bb0063a057dfb8b511e7162a78d4035278cf0a6.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 3, 2021, 10:17pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/18 "2021-05-03T22:17:41Z")

</div>

I’m glad it worked for you.

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 10:19pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/19 "2021-05-03T22:19:09Z")

</div>

Thank…I learned a lot now am working on change the codes in my app…

🙂

---

<div class="post-metadata">

**Author:** ![nmtabooks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nmtabooks/32/100232_2.png) [@nmtabooks](https://community.thunkable.com/u/nmtabooks)\
**Post date:** [May 3, 2021, 10:26pm UTC](https://community.thunkable.com/t/filter-local-table/1260996/20 "2021-05-03T22:26:54Z")

</div>

This is the final code…

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0fd39493b9a1dd3505b3d567f09d1a92e2ce9706.png)

If there is any suggestions… or changes needed please help me to clear it…

[Next page](https://community.thunkable.com/t/filter-local-table/1260996.md?page=2)
