How to Round a number with decimals with Server Data Formatter

Hello George ,

When will you update server side formatter ? Because some formatters really not enought for us…

For example we cant use round function on server side … like this round(2)…

I have been waiting long time ago…

I dont know this is bug request or new feature …

Serhat, not sure where you are looking at but with Server Data Formatter we have over 70 data formats for quite a while now and Round has always being there.

Yeap … it woks like this round() no problem but it doesnt work like round(2)

I need to round decimal

Check please
https://www.dmxzone.com/support/32648/topic/63118/

Round is just for full numbers Serhat. If you want to round with decimals just use the “Format Number”

George realy Thank you for your guide … I have been expecting this response for a long time and the project has stopped because of this reason. I can continue now.

:+1:

I am confused by this @George. I want to do a division calculation and round the result to 2 decimal places but end up with a number that I can then use in other calculations.

According to Wappler, the Format Number function will leave me with a string which potentially has a delimiter too.

How can I do a round to 2 decimal places and end up with a number? Do I then have to do a .toNumber() on the result? Or is there a .round(2) function somewhere that I can use?

Second Question…

I have just tried to do the above using the experimental mode user interface and I have ended up with this syntax:

{{$_SESSION.s_amount_to_pay / s_exchange_rate.formatNumber(2, ".", ",".toNumber())}}

Which I am sure is not what I need. I am looking to calculate:

s_amount_to_pay / s_exchange_rate

Rounded to 2 decimal places.

How do I create that equation on the server side?

Best wishes,
Antony.

aaa

Hello Antony,
It doesn’t matter if it’s on the server side or on the client side - when making calculations and want to use the numbers formatting options on a value which is not a number then you first need to convert it to number.
So (value1.tonumber + value2.tonumber).some_other_formatter

Hi there Teodor…

Thanks for your fast reply!

I feel happy with the converting to a number requirement.

My question is, on the server side, how to calculate

s_amount_to_pay / s_exchange_rate

creating a number as a result which is rounded to 2 decimal places.

(Both of these values are already numbers)

Can you show me the syntax to do that please?

Thanks!
Antony.

It simply:

{{(value1 / value2).formatNumber(2, ".", ",")}}

Screenshot_4