Changing custom Javascript field display format

Follow these steps to continue configuring a field at the dataset level using Javascript (js). See Changing the field display format for initial navigation steps.

  1. In the Edit Field Parameters window modal, under the Display Format tab, select Custom Javascript from the Category menu.
  2. Under Custom JS Format Function, enter the following js code:
    function myFunc(value) {            
      // Show the number in trillions with a dollar sign return
      '$${value/1000000000000}';
      }
    entering js format
  3. Click APPLY.
  4. Save the changes to the dataset.

    In this example, under Dataset: World Life Expectancy, click Save.

  5. To verify that the format applies to all new visuals that use the field, repeat the steps in Testing the calculated field..

Let's compare the visuals before and after we apply the js format on the gdp field.

  • Before we apply the js format, the visual displays the currency with many trailing zeros.
  • After applying the custom js format, notice that the trailing zeros no longer appear.
js-configured field display