Hi All,
Simple enough question no doubt.
I have a a container doing basic math. Two user inputs and expression as output
Var1 / Var2 * 100 (for example) which gives an output in the expression.
The variables are set as decimal because I want a decimal number, but it's showing as 24.213131313213 when all I want is 24.21 (for example).
I thought there'd be an easy way of changing this without me resulting to just writing my own JS. But I've just been down a rabbit hole with Trunc, Round, etc and I'm not getting anywhere. Could someone explain what I need to do just tot get 2 decimal places please
Hi Lee Perks,
These are the built in functions you can use
- FormatDecimal(Var1 / Var2 * 100,2,".","") //Returns Text- Round(Var1 / Var2 * 100,fractionalDigits:2) //Returns Decimal- FormatCurrency(Var1 / Var2 * 100,"",2,".","") //Returns Text
You can see the OutSystems documentation from below linkhttps://success.outsystems.com/documentation/11/reference/outsystems_language/logic/built_in_functions/math/https://success.outsystems.com/documentation/11/reference/outsystems_language/logic/built_in_functions/format/
CheersPankaj
I've actually tried this. I must be doing something wrong, new to out systems so getting hang of it with little things like this.
Hello @Lee Parks.
You can use the FormatDecimal() built-in function and set the number of decimal digits you want.
Format - OutSystems 11 Documentation
Regards,
Gabriel.
Hi Lee,Round(unroundedNumber, 2) should do the trick.
Hi @Lee Perks ,
I wonder what exactly your logic flow is when you are calculating that the Format doesn't work.
Would you mind sharing the oml file of your app? To generate the oml file, you can go to Module > Export > Save As..
Thanks.Regards,Bryan
Hi @Lee Perks
I think you should re-watch/review the Outsystems training
but basically, if you only need to display data with format use the built-in function of OutSystems
FormatDecimal and you will see the details of the parameters needed
you can also check other built-in functions like round () and formatcurrency() just like the suggestions on the previous reply from others outsystems developer/s.
i created a sample expression that displays the variable with no format, formatted, and round
this display on screen like this
or you can share your OML or instructions on how your application has been built