# Very basics operations in datafield

**URL:** <https://forum.bubble.io/t/very-basics-operations-in-datafield/88693>\
**Category:** Database\
**Created:** [April 28, 2020, 8:02am UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693 "2020-04-28T08:02:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fakossa](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fakossa](https://forum.bubble.io/u/fakossa)\
**Post date:** [April 28, 2020, 8:02am UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/1 "2020-04-28T08:02:31Z")

</div>

Hey, everybody!  
Newbie to Bubble, I’m stuck on a calculation method and its expression to perform basic mathematical operations on databases.

I’m confuse between using “calculate formula”, “mathjs” or doing my operations in the workflow.  
I just need to add and visualize the values entered in a data field “food distribution”, but how and where do I write the right expression?

Thanks to you

---

<div class="post-metadata">

**Author:** ![fakossa](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fakossa](https://forum.bubble.io/u/fakossa)\
**Post date:** [April 28, 2020, 8:06am UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/2 "2020-04-28T08:06:02Z")

</div>

Here is what I’ve tried with mathjs…

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/a/3/a3bf7126408a48972592822badedc10b2182c95c.png)

---

<div class="post-metadata">

**Author:** ![TipLister](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tiplister/32/150194_2.png) [@TipLister](https://forum.bubble.io/u/TipLister)\
**Post date:** [April 28, 2020, 8:11pm UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/3 "2020-04-28T20:11:59Z")

</div>

hi, so there is the plugin: math.js (local), which is an element you move into the editor (you are using it) and also mathjs (using a get api call)

for the local one:  
for example as the expression you can have input A`s value* input B`s value. (make sure the inputs have content type integer/number)  
then you can have a text element showing math.js A`s result.

You can also have a group, which has content type number and use it in the calculation or take parts of your repeating groups content. E.g. let us say you have a repeating group of files, which each have a nr. of likes. then you could take the first items number for instance and multiply it by something.

![2020-04-28 22_08_54-Backends _ Bubble Editor](https://us1.discourse-cdn.com/bubble/original/3X/4/6/4668f079561e34b758cf80ad7639da3bcf90e9c5.png) ![2020-04-28 22_08_12-Backends _ Bubble Editor](https://us1.discourse-cdn.com/bubble/original/3X/9/5/95f33adafde12423e38283928e83dd922787db95.png) ![2020-04-28 22_08_03-Backends _ Bubble Editor](https://us1.discourse-cdn.com/bubble/original/3X/e/4/e49284a8a40a23469f1eb69c721de1cb45cf175f.png)

for the get API one. select “Get data from an external API” inside a text element, when it says “insert dynamic data” to configure this

 ![2020-04-28 22_09_33-Backends _ Bubble Editor](https://us1.discourse-cdn.com/bubble/original/3X/b/2/b2b6cad7bb69fefb53483a4098d52192262b74c3.png)

Let me know, what exactly do you want to calculate?

regards,  
Julius

* * *

For short tips on Bubble & more check [tiplister.com](http://tiplister.com)

---

<div class="post-metadata">

**Author:** ![fakossa](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fakossa](https://forum.bubble.io/u/fakossa)\
**Post date:** [April 30, 2020, 2:08pm UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/4 "2020-04-30T14:08:39Z")

</div>

Thank you very much @TipLister for your precision and your help

---

<div class="post-metadata">

**Author:** ![fakossa](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fakossa](https://forum.bubble.io/u/fakossa)\
**Post date:** [April 30, 2020, 2:09pm UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/5 "2020-04-30T14:09:46Z")

</div>

What’s make you choose a solution rather than another? (local/api)

---

<div class="post-metadata">

**Author:** ![TipLister](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tiplister/32/150194_2.png) [@TipLister](https://forum.bubble.io/u/TipLister)\
**Post date:** [April 30, 2020, 2:59pm UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/6 "2020-04-30T14:59:18Z")

</div>

hi,  
well in bubble editor under plugins for “math js local” it says the following. So normally unless lots and lots of calculations I would use not the local one.

 ![grafik](https://us1.discourse-cdn.com/bubble/original/3X/2/a/2adf044c173d1ec091581f36ebc85241438a2d28.png)

---

<div class="post-metadata">

**Author:** ![janiskropp](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/janiskropp/32/156989_2.png) [@janiskropp](https://forum.bubble.io/u/janiskropp)\
**Post date:** [August 18, 2020, 12:30pm UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/7 "2020-08-18T12:30:53Z")

</div>

Hello @tiplister, did you ever have the problem, that saving your result to an data point was not possible or just saved a 0? I am struggling with this.  
in step by step I can see that the calculation was done correct. but still nothing is saved to my database… cheers

---

<div class="post-metadata">

**Author:** ![adityacc06](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@adityacc06](https://forum.bubble.io/u/adityacc06)\
**Post date:** [August 21, 2020, 12:56pm UTC](https://forum.bubble.io/t/very-basics-operations-in-datafield/88693/8 "2020-08-21T12:56:26Z")

</div>

Hello @TipLister,

As per you suggestion, I tried using math.js( local) plugin for simple Matahematical Calculation.

Only thing is that I have one **User-defined Input Number ( Decimal )** and **multiplied** by **Variable Number ( Integer)**.

**This Variable number is fetched from Database when user selects options from the Dependent Dropdown menu.**

After I do this, multiplication is not seen in the Preview Page.

So My questions are -

1. Can one use math js ( local) for multiplying **Variable Input ( Number-Integer)** by **User-defined Input Number ( Decimal )**
2. In math.js (Local) is it that Integer must be multiplied by Integer Number & Decimal by Decimal Number

Can you please suggest what must be gone wrong?

I have attached screenshots of my query.

 ![Math Js- Query](https://us1.discourse-cdn.com/bubble/original/3X/1/2/12b3e00ade7edd442dd38e9bdeafbd717d4e0311.jpeg)

So then, I also tried using Expression whose Screenshot is attached here

 ![Expression- Query](https://us1.discourse-cdn.com/bubble/original/3X/5/d/5d36ed651be2f0bf86e7eb61816909cc9a0b24c8.jpeg)

Your Help is much Needed Here.

Thanks
