cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

currency format. Be able to show coin value with a $ and .00

currency format. Be able to show coin value with a $ and .00

Sometimes we simulate cost. Great to have the possibility to select if the table value is currency.

Then instead of showing: 40000000

It would show: $ 40,000,000.00

With or without cents would be ok. But great for viewing values and showing it to the audience.

1 Comment
jon_abbott
Not applicable

Hi @Enrique Elizaga, in case you still need this functionality, here is a workaround solution:

1. Make a new user command
2. Enter in the following settings:

  • Name: financify
  • Parameters: (Variant n)
  • Return type: string
  • Example: financify(1234.56)

3. In the code editor for this user command, copy and paste the following code:

/**Custom Code*/
Variant n = param(1);
Variant dec_fraction = Math.fmod(n,1);

if (n < 1000)
{
    return (n);
}
int ndiv = n/1000;
Variant nmod = n%1000;
string nmod_string = string.fromNum(nmod);
string dec_fraction_string = string.fromNum(dec_fraction,2);

return (financify(ndiv)+","+nmod_string.padStart(3,"0")+"."+dec_fraction_string.substr(3,2));

4. Then call financify(number) from anywhere in FlexSim and it will return a string version of the number with commas as the thousand separator. A currency symbol can be added before it with "$"+financify(number). The code can be changed to use different thousands separators as well. Good luck with it! Hopefully FlexSim will add a currency unit selector in the Model Settings as well as support for format specifiers in a future release.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea