# 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

``````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

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