# :item from# :item until#

**URL:** <https://forum.bubble.io/t/item-from-item-until/6257>\
**Category:** Database\
**Created:** [September 22, 2016, 4:52pm UTC](https://forum.bubble.io/t/item-from-item-until/6257 "2016-09-22T16:52:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon39705632](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@anon39705632](https://forum.bubble.io/u/anon39705632)\
**Post date:** [September 22, 2016, 4:52pm UTC](https://forum.bubble.io/t/item-from-item-until/6257/1 "2016-09-22T16:52:10Z")

</div>

I have been working on my search functionality and pagination within the results set and made good progress, but hit a road block that I cannot get my head around.

To simplify testing I used small record sets and set paging size to small numbers. In theory if the setup is correct it wont matter the page size it should just work.

I make an initial query to determine the record count of the results set and then set a bunch of states in the Pagination control I have built. These include RecordCount, ItemsPerPage, Pages Available, Current Page, ItemFrom and ItemTo.

After these are set, I use them to display in a repeating group the query but add the **:item from** and **:item until** operators.

![](https://us1.discourse-cdn.com/bubble/original/2X/7/7f466fb36d34873e274a6d5edd1dd16abf298284.PNG)

Having read the documentation and done a few checks to determine which order the method chaining does work, I worked out that I need to perform the **:item until** first and then the **:item from**.

With a ItemsPerPage of 1 and ResultsCount of 5 it correctly sets up Pages available to 5 and Current Page to 1, the Page Next simply increments the item until and item from and re-displays in the group.

The problem I have is the number of records displayed on each page are as follows;  
Page 1: 1  
Page 2: 2  
Page 3: 3  
Page 4: 2  
Page 5: 1

So, the question is, am I using the **:item until** and **:item from** correctly in the right order in the same statement? I’ve been on this for hours today and it is really frustrating! I am sure I have been staring at this so long, and tried so many different things that I cannot see the wood for the trees now. 😫

---

<div class="post-metadata">

**Author:** ![fayewatson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fayewatson/32/2686_2.png) [@fayewatson](https://forum.bubble.io/u/fayewatson)\
**Post date:** [September 22, 2016, 9:44pm UTC](https://forum.bubble.io/t/item-from-item-until/6257/2 "2016-09-22T21:44:26Z")

</div>

Hey Dave I may not be understanding this correctly, but are you trying to display search results in a repeating group, and then display the next set of results within the repeating group when a different ‘page number’ is clicked? Instead of using ‘next’ and ‘previous’ buttons?

---

<div class="post-metadata">

**Author:** ![fayewatson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fayewatson/32/2686_2.png) [@fayewatson](https://forum.bubble.io/u/fayewatson)\
**Post date:** [September 23, 2016, 3:06am UTC](https://forum.bubble.io/t/item-from-item-until/6257/3 "2016-09-23T03:06:32Z")

</div>

I just tried working on this for a while and I think I got something working (I hope!).

Preview:

> **[Bubble - Visual Programming](https://forumapp3.bubbleapps.io/version-test/rgroup_pages?debug_mode=true)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

Editor:

> **[Bubble Editor - Forumapp3](https://bubble.io/page?type=page&name=rgroup_pages&id=forumapp3&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

I created two data types “Entry” (containing one field: “Name”, type: text, list: no) and “Page Number” (containing one field: “Number”, type: number, list: no). The main repeating group does a search for Entries, and there is a repeating group beneath it which does a search for Page Numbers and displays them 3 at a time.

![](https://us1.discourse-cdn.com/bubble/original/2X/7/7d26b781fcc5ca6e1755a996d370d4d72940d495.png)

On page load, I used custom states to count total the number of results in the Entry Repeating Group, and divided that by the number of rows in that repeating group which equals the Repeating Group’s “Number of Pages”.  
 ![](https://us1.discourse-cdn.com/bubble/original/2X/c/c085c9d1712b1b3e96eda47e47e0b941dee2b107.jpg)

The Page Number repeating group will only display numbers less than or equal to the Entry Repeating Group’s Number of Pages:

 ![](https://us1.discourse-cdn.com/bubble/original/2X/a/a574276cd982d5cd1bd832bda12dbecc46d01c6a.jpg)

On page load, I set the Entry Repeating Group’s Current Page to 1. Then when a next arrow, back arrow, or ‘number’ within the Page Number repeating group is clicked, it will ‘go to page’ in both repeating groups (Entry and Page Number) and continue to set the state of the Current Page number custom state. Not sure if this is what you’re looking to do, but just incase it may help 🙂

---

<div class="post-metadata">

**Author:** ![anon39705632](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@anon39705632](https://forum.bubble.io/u/anon39705632)\
**Post date:** [September 23, 2016, 3:35am UTC](https://forum.bubble.io/t/item-from-item-until/6257/4 "2016-09-23T03:35:58Z")

</div>

Thanks for that Faye, but that is using fixed list. and the Goto page functionality.

I am using an Extending Vertical List, hence the reason to try and get the :from and :until operators in the search query working correctly.

I want to fully understand the use of these operators and that is where I am banging my head and can’t get it to do what I want. I am beginning to think that they **do not** support method chaining and are simply overriding each other depending on the order they are put into the query…but I’m not 100% as to what is exactly going on.

More play to do…at least you have a nice paging example now in the ForumApp for others 🙂

---

<div class="post-metadata">

**Author:** ![fayewatson](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fayewatson/32/2686_2.png) [@fayewatson](https://forum.bubble.io/u/fayewatson)\
**Post date:** [September 23, 2016, 3:43am UTC](https://forum.bubble.io/t/item-from-item-until/6257/5 "2016-09-23T03:43:26Z")

</div>

Ohh! I see 🙂 That sounds like a very interesting problem to solve! Will follow along, and hope you find a solution!

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [September 23, 2016, 9:42am UTC](https://forum.bubble.io/t/item-from-item-until/6257/6 "2016-09-23T09:42:16Z")

</div>

Bubble tends to work left to right.

So if you have “From item” as 3 … and “To Item” as 5 … it thinks you mean 5 on from 3.

The solution is therefore to subtract your “From Item” number from your “To Item” and add 1 and use that in your search as “:ToItem”.

---

<div class="post-metadata">

**Author:** ![anon39705632](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@anon39705632](https://forum.bubble.io/u/anon39705632)\
**Post date:** [September 23, 2016, 9:45am UTC](https://forum.bubble.io/t/item-from-item-until/6257/7 "2016-09-23T09:45:15Z")

</div>

Thanks @NigelG, I have redesigned the page for now, but will try again later on another page which is planned.

---

<div class="post-metadata">

**Author:** ![anon39705632](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@anon39705632](https://forum.bubble.io/u/anon39705632)\
**Post date:** [September 26, 2016, 8:19am UTC](https://forum.bubble.io/t/item-from-item-until/6257/8 "2016-09-26T08:19:46Z")

</div>

Ok, I have made a demo page using a simple list, and it definitely does not do as I would expect from the definitions of the operators.

See the page here: [https://dave-auld-demo-stuff.bubbleapps.io/version-test/fromuntildemo?debug\_mode=true](https://dave-auld-demo-stuff.bubbleapps.io/version-test/fromuntildemo?debug_mode=true)

It appears that the order of the From Until or Until From does not matter, and Until is actually the number of items to return after the from! So, if From is 5 and Until is 10, it does not return 5,6,7,8,9 it returns 5,6,7,8,9,10,11,12,13,14

I’m not convinced it is working correctly for both operators being present in the statement, and which way round they are.

@NigelG does that make sense, or am I miles out on the expectations based on the definitions and potential method chaining.

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [September 27, 2016, 6:03am UTC](https://forum.bubble.io/t/item-from-item-until/6257/9 "2016-09-27T06:03:36Z")

</div>

Yeah, you are right, “until x” is x on from then item in “from”.

Or rather until #10 in the list that has been adjusted by the from.

So I guess the question is … is that working as intended (in which case we can ask for some wording updates) or should it work as it looks like it is described. Only @emmanuel can tell us 🙂

---

<div class="post-metadata">

**Author:** ![emmanuel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/emmanuel/32/27657_2.png) [@emmanuel](https://forum.bubble.io/u/emmanuel)\
**Post date:** [September 27, 2016, 6:49am UTC](https://forum.bubble.io/t/item-from-item-until/6257/10 "2016-09-27T06:49:12Z")

</div>

It sounds going to be from the from. It reads as this

(List: from n): to m

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [September 27, 2016, 6:59am UTC](https://forum.bubble.io/t/item-from-item-until/6257/11 "2016-09-27T06:59:49Z")

</div>

Returns a sub list from _the original list_, from the first item to the Nth one.

So I think the wording around “original list” is unclear ?

1,2,3,4,5,6,7,8,9 = the original list. So “Until 5” will give you … 5.

However if you do a “From 2” … the “Until” isn’t operating on the original list … is operating on a new list …

2,3,4,5,6,7,8,9 … “Until 5” is now 6.

---

<div class="post-metadata">

**Author:** ![anon39705632](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@anon39705632](https://forum.bubble.io/u/anon39705632)\
**Post date:** [September 27, 2016, 7:06am UTC](https://forum.bubble.io/t/item-from-item-until/6257/12 "2016-09-27T07:06:41Z")

</div>

And that is where I’m coming from, the method chaining should be acting on the result of the previous operator, so by switching the order of the From and Until should be making a difference to the output, however it doesn’t.

I tried to find to some example on some of the other databases operators e.g. Mongo or whatever, but haven’t found time.

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [September 27, 2016, 7:13am UTC](https://forum.bubble.io/t/item-from-item-until/6257/13 "2016-09-27T07:13:14Z")

</div>

Whilst I agree it isn’t all that clear how it works …

“Method Chaining” is all a bit code-y. Most people who use bubble are not coders, so I would suggest it should work in the way _they_ would expect it to work, rather than how someone technical expects it to work.

It is fairly confusing as it is.

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [July 10, 2019, 8:51am UTC](https://forum.bubble.io/t/item-from-item-until/6257/14 "2019-07-10T08:51:44Z")

</div>

@anon39705632

I share your pain as the theory behind item until would be that i want to label it as item until the specific number; meaning I want items from 31 until items 60, we as humans would natural assume the bubble “item until” should be 60 but in fact it needs to always be the number of results you want to have.

So in my app, which is set the same way as yours with custom states for the math, I have set the items until custom state to always be equal to the number of results I want displayed on page…now it works exactly as intended.

Page 1 shows items 1-30  
Page 2 shows items 31-60  
Page 3 shows items 61-90

because my items until is always 30 bubble does the math by saying

items from + items until = last item in list to be displayed

originally I had same set up as you and was confused…wrote on paper what was happening, saw the multiplication of my values for item until and couldn’t figure it out…read this post, specifically from Nigel and got it.

---

<div class="post-metadata">

**Author:** ![daniel45](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@daniel45](https://forum.bubble.io/u/daniel45)\
**Post date:** [August 5, 2023, 5:17pm UTC](https://forum.bubble.io/t/item-from-item-until/6257/17 "2023-08-05T17:17:58Z")

</div>

Thanks! This solution worked to me!
