Not allowing math answers to go negative

When inputs are set as integers or decimals and the workflow is set to ‘do a search for input a’ value - input b’s value:sum’ how do you keep the minimum result to 0? I don’t want the result to be a negative number. Thanks.


Hey there,

Can you possibly share an app that displays what you are trying to accomplish? This will help me to get a better idea of what you are trying to do.

I am only asking this because I currently do not understand the purpose of having “:sum” in the expression, as input b does not appear to be a list of anything, rather just a single value.

From what I can tell though, this could be done via a conditional statement. I’m assuming that there is a button that triggers the workflow you described, so you could have a conditional statement on that button that looks like this:

The above conditional statement would prevent the workflow from being run if the result of input a - input b is less than or equal to zero. Therefore, if a user inputs a combination of values that would cause the result to be equal to zero or be negative, the button will be disabled so the workflow cannot be triggered.


I appreciate the suggestion but im not trying to disable the workflow if the value<0. I want the workflow to run regardless of the answer. Real math example would be 3 - 5 = -2. I want to display 3 - 5 = 0, which I have done. The problem now is that regardless of the displayed answer being 0, the (-) answer gets stored and whenever I perform another computation it applies the real answer to the new computation. I would like to display 0 and reset all data when any answer results in a negative. Thanks. Hope this makes sense.

1 Like


Apologies for the delay in my response, and for my confusion with your original request.

To accomplish what you are looking for, you could do something like this:

You would have to different workflows setup that look like this:

The first workflow simply stores the number that the user inputs. It looks like this:

The second workflow only triggers if the user inputs a value that it less than 0. It looks like this:

Notice how in the above I have the and when statement. This is what checks to see if the user inputed a value that is less than 0. If the user did not input a value that is less than 0, the other workflow will be triggered. If they did input a value that is less than 0, this workflow will be triggered.

The actions that happen in this workflow look like this:

Notice how when the value that the user inputs is less than 0, the workflow simply sets the value that is stored in the database to 0. Therefore, when a user submits a value that is greater than 0, the actual value will be stored. On the other hand, when the user submits a value that is less than 0, that value will be ignored and 0 will be stored in the database.

You can check out the workflows for the app here: nonnegative | Bubble Editor and you can check out the app in action here:

Hope I helped, and feel free to ask if you have any other questions! :slight_smile:


1 Like

Hey thanks a lot for the help. I played with the settings but i’m still not getting the results that I am looking for. I see you have only one input field and the way you have it set up works great for that one field. But I have two fields A and B. And am trying to set the value of the total to 0 only if l. I am at a loss here.

Apologies for my confusion.

After looking at your project, is it correct to say that you want to check to see if input A’s value will cause the already existing value to be negative?

For example, if the number next to the buttons is 5, you want to make sure that the inputted number will not cause the result to be negative, if the inputted number is subtracted from 5?

That is correct.

Thanks for the clarification. I’ll go ahead and make a refined version of my original demo that is more applicable for this purpose.

Check out the revised demo here: and see the workflows here:

As you can see, I just replaced the check to see if the input is less than 0 with a check to see if the input + or - the already existing integer is less than 0.

Man thanks alot. :+1::+1::+1::+1::+1: I would’ve never figured that out.

But why are you using ‘make change to a thing’ instead of ‘create a thing’? I’m confused.

Also can you briefly explain how :first item works. Thanks.

Good questions!

I’m using make change to a thing in case the number already exists. You would only want to use create a thing (in this example) if it was your first time submitting a number into the system. However, in the event that it is your first time submitting a number into the system, I used the “create if the thing doesn’t exist” option. This way, Bubble checks to see if a base number is already in the system. If it is, then it will just edit that number. If it is not, then it will set the input as the number.

For the :firstitem setting, it is used to select the first item from a list of things. It is extremely useful in these kinds of situations because there is only one of a given thing. For example, the data type is “Number” and there is only one data entry for the type “Number” in the system. Therefore, I want Bubble to display the first item in the list of Number items, as there is only one number item.

I know that the above can get very confusing, so please ask if you want me to clarify further. I’m more than happy to help! :slight_smile:

I believe I understand. Thanks for all your help.

1 Like

Of course! I’m happy I was able to be of assistance!