# How can I filter a Google Sheets data source by certain factors?

**URL:** https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821
**Category:** Questions about Thunkable X
**Tags:** spreadsheets, data-viewer
**Created:** [May 19, 2021, 4:19am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821 "2021-05-19T04:19:08Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)
#### Post date: [May 19, 2021, 4:19am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/1 "2021-05-19T04:19:09Z")

</div>

Hi, there 👋 I hope you are doing well!

First off, let me explain the structure of my spreadsheet/database :

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

- There are 10 columns, and I want to filter the rows by 3 values - **Provisions** , **District** & **Tehsil**.
- What I want to do is let the user enter 3 things - choose a provision you require, and select your district and tehsil. So, now I have 3 values with me, provision, district, & tehsil (all the values I need to filter the database from). Then app proceeds to the next screen, where I show the filtered data.

Here is the filtration structure I need to build :

- First check if there are any Donors available who provide the user’s selected provision. If any, proceed to the next step. If none, then display NA.
  - Then check within the list of donors (who have the selected provision) if there are any of them available in the user’s district. If any, proceed to the next step. If none, then display NA.
    - Then check within the list of donors (who are available in the user’s district) if there are any available in the user’s tehsil. If there aren’t any, then display the list of all the Donors available in the **district**.

So, is it possible to filter a google sheets data source? I thought about one method, which is to load the database and iterate through each row of it, and then if the row satisfies the filters, then add the row to a local/temporary data source - and then display that local data source. Is this method useful? I haven’t tried it yet 😑

If you have any ideas/methods on how should I filter, it would be a great help to me 🙂  
Thanks a lot for reading!

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [May 19, 2021, 5:48am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/2 "2021-05-19T05:48:06Z")

</div>

this is the best kept secret of google sheets! (after microsoft provided the new powerful dynamic array functions in excel 365 but by subscription only, google is providing it to us, free!)

assuming your main data resides in the sheet called **donors.**  
 ![gs1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/a/aac704b559f26e3866458aab86558e88b0f498f4.jpeg)

put your search arguments in the sheet named **sel**.  
for testing just populate it by hand, but in thunkable, simply update this one row with data from an input form.  
 ![gs2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/8/48de38942211d99695b821f7e617237d4808a388.jpeg)

here comes the best part:  
create a new sheet called **result** and in cell a2, type the formula shown below. it means " filter from donors to here and apply the following conditions which are delimited by commas". (note that you don’t have to specify the ending rows!).  
Voila!

 ![gs3](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/9/29fee66dbb4d4ed9a47e121600cc6a1c0f0b492d.jpeg)

i have just discovered this trick recently and i take advantage of it whenever i can!

---

<div class="post-metadata">

### Author: ![anush\_bh20910](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/anush_bh20910/32/103923_2.png) [@anush\_bh20910](https://community.thunkable.com/u/anush_bh20910)
#### Post date: [May 19, 2021, 6:31am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/3 "2021-05-19T06:31:20Z")

</div>

You helped @kartik14, plus me ! i  
I was stuck in a bug but you helped me!

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [May 19, 2021, 7:05am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/4 "2021-05-19T07:05:04Z")

</div>

i’m glad i was able to help.

---

<div class="post-metadata">

### Author: ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)
#### Post date: [May 19, 2021, 8:01am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/5 "2021-05-19T08:01:00Z")

</div>

Hey Kartik! 👋

@manyone’s solution on the Google Sheets end looks awesome, but since you mentioned trying out creating a local view in Thunkable and displaying that in your project, I thought I’d share a project that demonstrates this here.

[Here is the project.](https://x.thunkable.com/projectPage/60a4b5823fb2e80012ce772e)

As you can see, when a genre is selected from the List Viewer, I populate a local Data Source with items from my main Data Source that match this genre. Then I display the matching data in a Data Viewer.

I filter by one criterion, but you can easily modify this to filter by 2 or more criteria! Just add extra `filter list` and `filter criteria` fields as inputs to the `show filtered data` function, and link a few conditions together using and blocks in the `if` statement inside the function.

I’ll write a more detailed tutorial about this soon, since multiple Thunkers have asked about it, but I hope this demo project is helpful to you (or to someone reading)!

---

<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 19, 2021, 8:42am UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/6 "2021-05-19T08:42:39Z")

</div>

This is my contribution demo

[https://x.thunkable.com/projectPage/5fb9fb1dbfeb240011084d78](https://x.thunkable.com/projectPage/5fb9fb1dbfeb240011084d78)

The project shows both single selection and multiple selection examples.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/how-can-i-filter-a-google-sheets-data-source-by-certain-factors/1292821/7 "2024-11-08T13:22:28Z")

</div>


