# I can't save a list of numbers?

**URL:** <https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641>\
**Category:** Database\
**Created:** [November 8, 2022, 10:02am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641 "2022-11-08T10:02:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [November 8, 2022, 10:02am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/1 "2022-11-08T10:02:38Z")

</div>

I have two inputs (Quantity and Price) and when ‘save’ is clicked I want to save the quantity x price to a custom state [list] so I can later display the :sum.

The custom state is always asking for more info but why? Both the inputs and the data type are integers. The custom state is a list. What’s missing?

 ![Screenshot 2022-11-08 095751](https://us1.discourse-cdn.com/bubble/original/3X/2/4/245df5d99f38fca0b6130fd64f642b8a454046eb.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [November 8, 2022, 10:33am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/3 "2022-11-08T10:33:13Z")

</div>

The custom state is a list… so it expects a _list_ of numbers…

You’re trying to set it to a _single_ number - hence the error.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [November 8, 2022, 11:22am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/4 "2022-11-08T11:22:48Z")

</div>

> [@adamhholmes](#):
>
> You’re trying to set it to a _single_ number

I think I should be settings to a list but not sure how to do that, I don’t have the option to use the ‘each item’ function despite the custom state being a list.

For clarity, the user inputs as many items as they want and I will save these to the custom state. Then I will show the total (so I think I need a list right?)

 ![Screenshot 2022-11-08 112112](https://us1.discourse-cdn.com/bubble/original/3X/6/d/6db127c8c568b01f3d8c9106563f097e7d2f96d6.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [November 8, 2022, 11:35am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/5 "2022-11-08T11:35:41Z")

</div>

To add to a custom state list you need to use ‘plus item’ after the existing list value…

i.e. `create-estimate's _calculate: plus item: inputEstQuantitys' value * inputEstUnitPrice's value`

But, bear in mind that (for most purposes) lists in Bubble can’t contain duplicate values… so your custom state list of numbers won’t be able to hold the same number more than once.

So, if you have, for example `Item 1: 2 x £50` ` Item 2: 4 x £25` and `Item 3: 10 x £10` your custom state list will only contain a single number (100), so the sum of that list will be £100, instead of the actual sum of the 3 items (£300).

To get around that issue, you can use a custom state list of Texts (instead of numbers), and ensure that each text in the list is unique (by using some unique identifier, followed by the price). Then you can spit the texts and convert them back into numbers to do the ‘total’ calculation correctly.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [November 8, 2022, 11:38am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/6 "2022-11-08T11:38:52Z")

</div>

Ok thank you @adamhholmes I think I understand, phew that is harder than I hoped lol… I will play with this and see if I can get it to work. Thank you for the clarification on duplicates, I didn’t know that.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [November 8, 2022, 11:49am UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/7 "2022-11-08T11:49:24Z")

</div>

> [@adamhholmes](#):
>
> by using some unique identifier, followed by the price

I have it working with type text, but can’t figure out what identifier to use, can you suggest anything?

 ![identify](https://us1.discourse-cdn.com/bubble/original/3X/3/0/30ae333be1874a1bcf595ec53086cf0d1d77ba1a.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [November 8, 2022, 12:00pm UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/8 "2022-11-08T12:00:31Z")

</div>

You could just use a simple number, corresponding to the list item number…

Or, in your case, you could use the Item name

Or, if you’re using items from the database, I’d use the unique ID of the item.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [November 8, 2022, 1:19pm UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/9 "2022-11-08T13:19:29Z")

</div>

Good idea, I can use the description, however how do I add the price to the end of the description in the formular?

 ![attach](https://us1.discourse-cdn.com/bubble/original/3X/b/2/b2beeb7249d50c1a5d09eb31594e78e3e1996645.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [November 8, 2022, 1:30pm UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/10 "2022-11-08T13:30:25Z")

</div>

Here’s a simple example…

[Item Quantities (bubbleapps.io)](https://design-test-app.bubbleapps.io/version-test/item_quantities)

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [November 8, 2022, 4:05pm UTC](https://forum.bubble.io/t/i-cant-save-a-list-of-numbers/231641/11 "2022-11-08T16:05:29Z")

</div>

Thank you so much for taking the time to create that example, I’ve learned a lot and I like the alert you added for duplicates. I have it all working but saving the data to the database is complicated because I have two custom states, “calculate” which folllows your example, and “lineItems” which should save the data to the Datatype Line Items. I am still working on this but wanted to thank you for the last post.

@adamhholmes I ended up using a combination of your solution with something else but have it working exactly as I wanted now. Thanks again for your help, I am constantly struck by the amount of Bubble knowledge you have and your generosity with your time.
