MikeTamoush
Qrew Commander
2 years ago
Solved

# Performing Multiplication in Jinja for Pipelines

I am trying to set a field to

[MyField] * .68

I tried this:

{{a.MyField  .68}} but that syntax wont even save. I also tried {{My.Field}}*.68. This saves, but produces an error when the pipeline runs. I know I could make a field in my Trigger table that does this calculation, but I would rather learn how to multiply in Jinja!

------------------------------
Mike Tamoush
------------------------------
• Round to 2 decimals: `{{ "%.02f" | format(MyField * 0.68) }}`

------------------------------
Doug Henning
------------------------------

### 8 Replies

• Assuming that [MyField] is a variable in your Jinja2 template that contains a numeric value, you can use the following expression to multiply it by 0.68:

```
```{{ MyField * 0.68 }}
```

```

This expression multiplies the value of [MyField] by 0.68 and returns the result as a new value. The result will be a float value if [MyField] is a float, or an integer value if [MyField] is an integer.

------------------------------
Shane Miller
------------------------------
• I mistyped in my post. I should have said I tried {{MyField * .68}} and it would not work.

However, {{MyField * 0.68}} DOES work! Thank you! Turns out that leading zero is important.

------------------------------
Mike Tamoush
------------------------------
• 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
------------------------------

• Just to elaborate, you would drag your [MyField] field from the pre-populated list on the right side into the field that you want the calculation to occur in. This will automatically format the field name for you by putting the appropriate step number a. or b. etc along with the {{ }} in the correct position

------------------------------
Shane Miller
------------------------------