Forum Discussion
Any idea the syntax to round the number to 2 decimals?
I tried {{MyField * 0.68 | round(2) }} but this did not work.
------------------------------
Mike Tamoush
------------------------------
Round to 2 decimals: {{ "%.02f" | format(MyField * 0.68) }}
------------------------------
Doug Henning
------------------------------
- ShaneMiller13 years agoQrew Cadet
You're gonna laugh... well, or cry, depending on how long you've worked on this. go to the outcome fields properties.
Change this to 2 for 2 decimal places:
------------------------------
Shane Miller
------------------------------- ShaneMiller13 years agoQrew Cadet
If you wanted to get fancy and do it in JINJA2 pipelines then plug this in:
{{ (MyField * 0.68)|round(2) }}
------------------------------
Shane Miller
------------------------------ - MikeTamoush3 years agoQrew Elite
Shane,
Regarding the field properties, I did have that set, and so it works when viewing the record (field rounds to 2 decimals). However, if you are editing the record, the field still shows the initial input, which in my case was autofilled from the pipeline and had 4+ decimals. While maybe no one would notice, my OCD really wanted it filled with only 2 decimals :)
Regrding your syntax, I agree that should work but for some reason, it is not working. round(2) in all documentation I googled seems to be what I would want, though it simply did nothing. However, Dougs solution did work.
Happy to have a solution, but that solution is the least intuitive thing I have ever seen lol.
Also, this entire time I could have simply made a field in my QB table, and had that field populate during my pipeline, but I really wanted to learn the proper Jinja code to do it without adding that field.
------------------------------
Mike Tamoush
------------------------------