Problem with calculation / Expression element

Hello everybody,

I know that some of you had some problem with calcultation. There is a good answer to that with Keith message using the Expression element.

When I am using this element, I have a problem with the expression value as you can see below :
Capture d’écran 2020-02-26 à 12.33.48

When the result of my expression is a decimal, the Value only take the numbers after the comma. It’s only work correctly when the result is an integer (when I rounded the result to 0).

Capture d’écran 2020-02-28 à 15.56.43

Capture d’écran 2020-02-28 à 15.57.02

I probably did something wrong, or misunderstood how this element is working.
Do you have any suggestions about this ?

Thanks a lot,
Audric

Any suggestion here ?

I have now another problem with the expression element, the value is wrong regarding the expression …

Thanks for your help

What’s the code you’re running in Expression? Let’s see how it’s set up…

Hello @keith,

Thanks for your response. I am using 3 variables in the calculation :

  • The min / max value of a slider
  • A input value
  • a database value

Here is the code running in the expression :

and the result in my page :

Thanks for your help :slight_smile:

First: I don’t see why you need Expression for this. Bubble will calculate:

some_number * some_other_number / some_third_number

just fine.

Example in editor:

Runtime:

As for what’s going on in your Expression, is its type set properly (it should be of type number obviously)? Are you sure of what your input values are? Etc., etc.

The screenshots I show above show how you can debug this, of course. But there’s no reason to so this calculation in Expression anyway, so… ?

Hello @keith,

Actually I broke down these two calculations because then I want to subtract the Expression min. to the Expression Max. (and maybe another calculation)

I could put these values in states, but I need to do it for 6 different inputs, so I didn’t want to put all the calculations in workflows, afraid of slowing down the page which is already running lots of workflows … doesn’t it ?

The type is set as this, decimal for the imput, number for the data, and number for the slider as show below.
Capture d’écran 2020-03-24 à 10.08.53 Capture d’écran 2020-03-24 à 10.08.46 Capture d’écran 2020-03-24 à 10.08.39

I just don’t understant why the expression element return a value of 8 when it should return 12 ?
I followed your instruction with the text element and it’s working ! But when I enter the same expression in the Expression Element, I get the same problem as explain in the first place … problem with the value which is different from the expression result …

Capture d’écran 2020-03-24 à 10.24.15

It just make non sense to me and I want to figure out why.

Thanks

This topic was automatically closed after 70 days. New replies are no longer allowed.