5

It seems to me a completely unnecessary problem not to be able to use fomarDecimal in expression

.I have such a simple example: I have two numbers, I want to give the value of the first one as a proecent of the second one.

The task is super simple - just divide one number by the other in the parameter, then multiply by 100.

Of course, the result is a number like "68.905121447768335528". The easiest way would be to use formatDecimal to limit this number to, say, two decimal places.

However, while

`formatDecimal($FirstValue : $SecondValue *100)`

works, adding the parameter '#,###.##'

`formatDecimal($FirstValue : $SecondValue, '#,###.##')`

returns an error, as this parameter cannot be used in the expression.

```
Invalid argument types (Decimal, String).
Function 'formatDecimal' expects argument types (Decimal)
```

Of course, there is a possible way to bypass this, just use the idiot trick using the string operations:

`substring(formatDecimal($FirstValue : $SecondValue *100), 0, find(formatDecimal($FirstValue : $SecondValue *100), '.') + 3)`

The result is: "68.90"

But that's just silly (although it works), and it's for now the only way to get formatting numbers calculated in expression. However, you have to perform unnecessary operations (such as dividing the same number twice). Or you calculate this value in an entity and display it from the number value formatting level which is also pointless

asked

Ćukasz Walczak

1 answers

I second this idea!

Just for future reference, another user in this forum thread suggested this workaround for those of you that just intends do format a decimal with 2 digits:

`formatDecimal(round($DecimalNumber, 2))`

Created

Vinicius Strugata Ambrosio