Mathematical calculation

Hi All,

how can I have 2 labels, Label A containing a number and label B needs to be 33% of Label A rounded to 0.5

So if Label A is 21, label B should be 14

All of this in one single page and without a button to press to calculate, as soon as label A changes label B should recalculate

Pretty new here and still learning and testing the tool but here is my suggestion:
Bind Label A value to a pageVar ‘labelA’ so that value 21 be stored into that var.
Bind label B to another pageVar ‘labelB’, and set its value as a formula with something like pageVar.labelA*0.33

Thanks, this part is done, any idea how to:
Round the result to 0.5
Have max 1 digit after the decimal

1 Like

I don’t know the formula by heart but there should be one enabling that here
https://docs.appgyver.com/docs/formula-functions-reference

I have tested a few, but I struggle to use them,
Can I just use a comma to separate 2 formulas, like in the image below?

Also I keep getting the error, ‘this binding requires an inversible formula’’

1 Like

Your formula should be like:

CEIL(pageVars.A*0.4: 5)

where “5” is a number I picked as an example. In your case, it should be the number you want to round.

But looks like you first need to get acquainted with how formula works. Do you know Excel formula? You should apply the same principles here.

Also, do not use an input field for displaying the result of your math formula. That’s why you have an “inversible” error message. Simply use a text component for such display purpose.

Thanks Fred, I changed the input field to a text component, but I still cannot make the formula work,

The formula is applied to a text field and the idea is that it looks at what is in the input field above assigned to var A and first calculate 40% of it and than make sure it rounds the number down to 0.5

When I type the formula like you did I get this error

I know the basic of excel, pivot tables basic if formulas but nothing to deep :joy:

Sorry, input just this
CEIL(pageVars.A*0.4)

However I’m still not sure how you can round it to 0.5.

You can use ROUNND(valueToRound, 2) If you want to round up to 2 decimal point, want 4 decimal point use 4 instead of 2.

Hope this will Help!

1 Like

Thanks Bravo, but this will also round to numbers like 5.6 and 5.7 etc…
The idea is that the numbers I will use are weights, and the smallest weight I have is 0.5kg
so if the calculation says I need to use a weight of 6.74kg the round formula needs to show 6.5kg,
if the calculation was 6.76kg than the rounding needs to go to 7kg

I hope it makes sense, I don’t know if this is even possible.

Sorry for the miss understating, I thought you wanna round the decimal points.

For your case I think the following formulae will help! Just try using this.

CURRENCY_FRACTIONAL(decimalprice: Number, unit: Number) => Number

Get more about the formula Currency_functional - financial

Hope this will help!

1 Like