Override the default number format

Canvas includes the accounting.js library. With accounting.js you can do advance formatting for number, money and currency.

The default number format is:

  • Thousands separator: ","
  • Decimal separator: "."

There are two ways to update the default format.

1. Override the format for the all application

The default number format is defined by applications. To update the default format for the all application, you need to update the client.startup.js:

  • C:\CWAS\webapps\<application name>\js\client.startup.js

For example to show "." as thousands separator and "," as decimals, you will need to add the following lines:

    accounting.settings.currency.thousand = '.';
    accounting.settings.currency.decimal = ',';

It is going to update the format for all numbers:

2. Override the format for a specific DBR

To override the format for a specific DBR, you need to add to the DBR the attribute tm1-accounting-settings-override. For example to show a "," as thousands, "." as decimal and a precision of 2, you need to add:

  • tm1-accounting-settings-override="{currency:{thousand:',',decimal:'.',precision:'2'}} "

Save the file and refresh the page, now you should see the DBR with the new format:

The attribute tm1-accounting-settings-override overrides the attribute tm1-data-decimal. For example if you have tm1-data-decimal="2" and  tm1-accounting-settings-override="{currency:{thousand:',',decimal:'.'}} " in the same tm1-ui-dbr:

It will show a value with no decimal because the default precision of accounting.js is 0. To see a precision of 2 you need to add precision:'2' to tm1-accounting-settings-override: