# How to get the last 10 items from Google Sheets

**URL:** <https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270>\
**Category:** Questions about Thunkable X\
**Created:** [March 28, 2021, 4:47am UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270 "2021-03-28T04:47:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 28, 2021, 4:47am UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/1 "2021-03-28T04:47:13Z")

</div>

I want to get the last 10 items from Google Sheets, but so far, it’s not working.  
Here’s my code:

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

I have 13 items in my spreadsheet, so, ideally I should get all the items from the 3rd row to the 13th.

But, this is not working. I’m receiving 13(which is the length of my spreadsheet) as variable i in my alert message. What should I do?

Thanks.

---

<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:** [March 28, 2021, 5:03am UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/2 "2021-03-28T05:03:38Z")

</div>

The number of rows from 3 to 13 is actually 11 so I think you instead want rows 4 to 13. But besides that I would expect the Alert to display 3, then 4, then 5, etc.

If it’s only displaying once and only showing 13 then it means that your “count with” loop is completing all of its iterations without pausing for each Alert cycle.

Try adding a wait block and see if the alert appears with different values. Or just use a label and a wait block instead of the alert.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 28, 2021, 5:06am UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/3 "2021-03-28T05:06:05Z")

</div>

Sure! Thanks for that. But even weirder is it’s repeating values and skipping the middle ones.

For example, it’s displaying the values from row 5 twice and then from row 7, without displaying row 6’s values. It’s basically replacing row 6 with values from row 5 again.

---

<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:** [March 28, 2021, 5:48am UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/4 "2021-03-28T05:48:46Z")

</div>

If you’re talking about the alert then yes, that’s unexpected. If you mean the Google Sheet values aren’t correct then I think I know why.

You’re asking the create row block to use get value blocks. Those get value blocks are going to take some time to retrieve the value. And the create row block isn’t programmed to wait. To correct that, I would assign the value of the Book name to a variable and then use the variable in the create row block.

In addition, you have a create row block inside of a very fast “count with” loop which probably doesn’t give the create row block enough time to complete… except maybe if the alert pauses everything until you confirm it. Not sure there.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [March 28, 2021, 10:39am UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/5 "2021-03-28T10:39:41Z")

</div>

No, what I’m talking about is the data viewer list. My Google Sheet is correct, but the data viewer list is wrong.

This is what I’m talking about:

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

And my DVL:

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

I was watching the label closely, and realized that instead of going from 3 to 4, it was jumping from 3 to 5 and 5 was jumping to 7 and not 6.

Here’s my code:

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

Any ideas for corrections?  
Thanks.

---

<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:** [March 28, 2021, 4:14pm UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/6 "2021-03-28T16:14:45Z")

</div>

If you remove the create row for a moment and test it, does your label count up correctly?

Is that entire set of blocks inside of anything except a simple event block (e.g. when screen opens, when button is clicked)? Because if it’s in a loop as well, that can cause a problem.

---

<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:25pm UTC](https://community.thunkable.com/t/how-to-get-the-last-10-items-from-google-sheets/1191270/7 "2024-11-08T13:25:44Z")

</div>


