Skip to content

Change Numeric Values to Display 2 decimal Places

Santam Chakraborty edited this page May 14, 2024 · 1 revision

In order to change numeric values calculated from PRO results to display upto 2 decimal places especially in Views Results, you can use twig functions.

To do this:

  1. Select the individual field in the views.
  2. Go down to the section titled "Rewrite Results"
  3. In this check the checkbox titled "Override the output of this field with custom text". This will enable you to overwrite the reuslts.
  4. Click the replacement patterns link below this to see all the replacement patterns available for this.
  5. Carefully select the replacement token corresponding to the "raw value" for the field. Please remember this will show all the replacement tokens available for the field so ensure that the correct value is selected.
  6. Add the following snippet after the replacement token value with a pipe "|"

{{ field_eortc_qlqc30_cf_score__value|number_format(2, '.', ',') }} In the above example field_eortc_qlqc30_cf_score__value is the raw value of the field_eortc_qlqc30_cf_score field.

See the image below

image

Clone this wiki locally