# Calculations for a derivative field

Hi, Sorry if this is a basic question but how do I populate fields with the results of calculations? e.g., If I have ‘Good votes’ and ‘Total votes’ and I want to populate a third derivative field called ‘% Goodness’ where: ‘% Goodness’ = ‘Good votes’ / ‘Total votes’ * 100 (and add a % - I can’t find a % number type in there).

Thanks

Simon

Is this in a workflow, or an element on the page?

If this is in a workflow, you can just create a field named % goodness and define it as your formula, getting the data from some inputs and then picking ‘/’ in the dropdown to build the expression.

If it’s an element, the expression is the same, but it’s just where you put it that is different. it’ll be in the content property at the element level.

Makes sense?

Hi both/all. I’m really struggling with this one, actually. Any help would really be very much appreciated?!

I also need to populate some fields with the results of calculations, I need to allow the user to input a couple of numbers, and my app then crunches these numbers using a fixed formula my end. I can see how to create a calculation solely from the user inputs, but not how to create a fixed formula? It’s probably so basic I can only apologise, but I am completely stuck!

Expanding on your example Simon, if the User were to manually input two numbers …let’s say that first ‘Good votes’ number input by a particular user is ‘1,000’, for example… followed by a second number expressed as a percentage …and let’s say the 2nd ‘Total votes’ number is ‘10%’… so that would read ‘1,000 / 10% = (answer 10,000)’ input by the user. I need to then further crunch that 10,000 answer with fixed back end calcs of, say, *(100/(120/3)). How would I do this, please?

So, that example would be; 1,000/10%*(100/(120/3)); or

1,000 / 10% = answer 10,000;

10,000 * (100/(120/3)) = new answer 25,000

Sorry if this is kindergarten stuff, but I’m completely stuck?

Thanks

John

I’m not sure i’m getting your question here. You can create a formula when you save the data, for instance. Something like this:

One thing to keep in mind is that Bubble’s expressions don’t support parentheses (yet), so you might have to do your operations in a few successive actions. It’s not ideal, but that’ll do it (until we have parentheses).

Yes, I can create a formula from inputs, where the user manually types in (in your img example) “input number 1s value” might be 1,000, * “input number 2s value”, which might be 10%.

But I need to these user inputs to form only the dynamic aspect of the formula. I need the 2 user inputs to then be calculated with a fixed formula built into the app, eg, (100/(120/3)).

Other words, the next user might input 1500 followed by 11%, and my app calculates this new dynamic aspect of the sum by (100/(120/3)).

So how do I create the (100/(120/3)) as a fixed formula which ‘crunches’ whatever 2 dynamic numbers the user inputs?

Update…please hold back on a reply for the time being, I think I’ve come up with a work around. If it works, I will post it up for others

Cool, let us know.

Hi all,
I just wanted to know when will parentheses be supported ?
I’m trying to make an app to calculate compound interests but I have trouble to do it in several actions.

thank you !

We don’t have a strict timeline on that one

@Valmon

What I found helped was to populate some fields or input boxes with a value, (just a straightforward case of ‘this input box has a value of x’, for example) and to cross reference that in any dynamic calculation you need to calc your compound interest.

Initially filling out a few fields this way might seem a little bit timely and cumbersome…but it’s a lot less timely and cumbersome than coding (trust me !)

1 Like

@emmanuel Where is this “content property” at the element level that you speak of? I cant seem to see anything call property or properties, could you please attach a screenshot of where it is and what it looks like?

Best,

Chris

This is just the top property of a text element, where you define what it displays

@emmanuel ok here is a screenshot of what I think is the “properties” section. Can you please explain how I can get this text box to display the number 9, based off of the calculation 33? Typing in "val = 33" doesnt work

I am trying to figure out how to do custom math formulas in bubble, and I cant seem to get it.

Well if we’re talking about static numbers, why don’t you just type 9? If it’s dynamic, then you click on ‘Insert Dynamic Data’, pick a field that is a number, and then you’ll see some operators show up in the dropdown menu.

Did you do the lesson ‘voting app’? It shows you how to build a voting system. The math there is simple, just incrementing votes by 1, but the logic of the interface is the same.

Yes, as long as you start off with a number you can spin out as long a formula as you like…

@emmanuel yes I did the Voting App lesson, but that was doing a formula inside a workflow. I am trying to do a formula that exists outside of a workflow.

So here’s what I need to do.

I want to count up the number of Contacts which have their Outreach Status field set to “Engaged”, and divide this by the total number of Contacts in the table. Outreach Status is a text field, set by a dropdown menu.

I am able to get the count of total Contacts, but I am not able to get the Count of the number of Contacts which have the Outreach Status set to “Engaged”

In the screen shot, the current formula is not returning a number, but rather just a “Yes” or “No”. How do I get it to return a number?? I’ve thought about doing a “count:” but this is not an available field

Ok thanks for everyone’s help. I’ve solved my own problem. Looks like you have to do a search for “Contacts”, then in the other window which appears, set a constraint to Outreach Status = Engaged.

See my screenshot of the working formula, and search with proper constrains

3 Likes