Math in rewrite result in Views

Created on 5 June 2016, over 8 years ago
Updated 26 July 2022, over 2 years ago

In Views it is possible to rewrite the output result of a field.
If choosing:
'Override the output of this field with custom text', I can read leading text:
'You may include HTML or Twig. You may enter data from this view as per the "Replacement patterns" below.'
What I need is some simple math, like a division of the actual field. In Twig documentation I have found that both division / and floored division // among other math function is possible in twig. Trying this in Views I do not get the right result.
I have an integer field {{field_ute}} that have 140 as output. When trying maths on it I get these results:
{{field_ute}}=140
{{field_ute/2}}=0.5
{{field_ute//2}}=0
{{field_ute+10}}=11
The math operation is done but the field value are always set to 1 regardless of what the value really are.
What have I done wrong?

πŸ’¬ Support request
Status

Closed: duplicate

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 14 hours ago

Created by

πŸ‡ΈπŸ‡ͺSweden chrotto

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States CProfessionals

    Just as an added note. Set the thousands marker to any field value to "none" otherwise it runs operations like the value is a string (I think) and makes the value 0.

Production build 0.71.5 2024