Calculations and maths in variables

When creating variables, it would be really useful to be able to include maths and text when defining a variable, which are kept up-to-date based on current values.

E.g.
With a shopping basket, I have the following variable
• Subtotal# (numeric)
Into which I add the value of each product selected in the basket.

From this value I would like to calculate
• VAT# (numeric) = Subtotal * 20%, truncated to 2 decimal places

And then display these variables in a currency
• Subtotal£ (String) = “£” + Subtotal#
• VAT£ (String) = “£” + VAT#
• Total£ (# String) = “£” + Subtotal#+VAT#

This way, I could just add/remove the product costs from Subtotal#, and use the strings for display in the prototype.

Hi @Dave_Curtis, my new plugin does exactly what you want, give it a try!

Here’s the list of your expressions, but with the syntax of my plugin,
just paste these {{ }} expressions into the description fields of the corresponding variables and run the plugin Dynamic Variables → Start Monitoring Changes or Dynamic Variables → Update Once:

• VAT# (numeric) = {{ $Subtotal * .2 }}
• Subtotal£ (String) = {{ "£" + ( $Subtotal ).toFixed(2) }}
• VAT£ (String) = {{ "£" + ( $VAT ).toFixed(2) }}
• Total£ (# String) = {{ "£" + ( $Subtotal + $VAT ).toFixed(2) }}

Hope this helps!

And here’s the video showing how the plugin works in action based on your request: