formatDecimal function not accepting 2nd argument String

I want to have my decimal in a formatted string. I decided to use formatDecimal. According to the documentation I should be able to give the Decimal as an argument and then a template string as a 2nd argument to determine the formatting. But for some reason I kept getting errors. Even when I copied the example from the documentation I got an error. formatDecimal(1234.56, '#,###.#') The error I get in the expression editor is the following: ‘Invalid argument types (Decimal, String). Function formatDecimal expects argument types (Decimal).’  The project I'm working on is using 9.12.0 modeler. What am I doing wrong? Is there any setting I need to update in order to use the formatDecimal function as described in the documentation?
2 answers

At first I thought you were doing this in a nanoflow. Aparently not. But this part of the doc tells you that it indeed will not function were you are trying it:


Hello! I was in kinda of the same picle, I couldnt’t use the text box because it was a text made using expressions. So this was my solution, string functions!


First, you format the decimal to string using formatDecimal. This will work anywhere, but it will just format to a string with no special formatting.

We will need to check if the decimal is in fact a decimal and has a point, we do that by using the find function, we pass our formated string and the “.” point parameter, and we check if it doesn’t exist, if it doesn’t, the function will return -1, we just check if that is the case and we just return the number which won’t have any digits after the point because it doesn’t have a point.

But if that isn’t the case and there is a point, we will need to know where that point is using the same find function, then we just take that value into a substring function to get that part of the string, but we don’t want the numbers just to the point character, so we add a +3 to get two digits after the point, you can increase this number if you want more precision :)


if find(formatDecimal($DecimalNumber), '.') = -1 then formatDecimal($DecimalNumber)

substring(formatDecimal($DecimalNumber),0, find(formatDecimal($DecimalNumber), '.')+3)


And then you can format and add “,” and “.” by checking the lenght of the string and adding to the string