261
Views
6
Comments
Solved
decimal places output on expression
Question
Application Type
Reactive

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

UserImage.jpg
Pankaj Jain
Solution

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 link
https://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/  

Cheers
Pankaj

UserImage.jpg
Lee Perks

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.

2021-05-18 19-42-11
Gabriel Melo

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.

2022-07-11 14-05-36
Jeroen Barnhoorn

Hi Lee,
Round(unroundedNumber, 2) should do the trick.

UserImage.jpg
Pankaj Jain
Solution

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 link
https://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/  

Cheers
Pankaj

UserImage.jpg
Lee Perks

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.

2024-03-23 18-16-49
Bryan Villalobos

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

2023-01-11 14-38-58
TESI-Sherwin

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.