Calculation formula within variable input

Would love this feature also!!

This really is a key feature to enable scalable design systems. Would be super grateful if this could be added.

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!
https://www.figma.com/community/plugin/1365339609215368041/dynamic-variables

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!

1 Like

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

Hey @A_Gussenberg, I just wanted to let you know that my new plugin Dynamic Variables does exactly what you’re looking for!
Here’s a quick video to show you how it works:

https://www.figma.com/community/plugin/1365339609215368041/dynamic-variables

@Josh_Mitchell your request is super close to this one, I posted video there too:

Let me know if you have any questions!

3 Likes

Thanks @neelts - this looks really promising.

1 Like

Please Figma team, add this feature

Basically Excel/Sheets like input possibilities, that would make prototypes more lively and real.

I’d love to see a number to HEX converter (text) “HEX(red-value)” (or something like that) and the possibility to use a text variable as colour. That would be possible if variables would allow formulas as value.

+1

+1 for this for sure…

+1 for this

Co-signing yet another great and much-needed feature. Love Figma, keeps getting better—let’s keep pushing it with new features like this. :slight_smile:

+1 for this great idea

This feels like a function that was missed, among others. Definitely need this feature…+1000000000

+1 here.
Also formula on colors would be fantastic! With this feature I’d be able to set main theme color and automatically derive all intermediate colors from it.

+1 as well. This would be a gamechanger and making base components a lot easier

+1. Yes, please. It would be awesome!

Penpot will have this feature pretty soon.

Let’s keep this one alive, even though it might be a micro-feature. It’s similar to a few other features I’ve been looking around at, so I hope it gets lumped in with those.

Praying the Figma dev team adds this soon! It seems like a small addition considering that we already have variables.

NEED THIS +1 this is extremely helpful if you are showing your designs in static mode to clients to give them an easy understanding of something you are trying to convey - I am not a prototyper nor do I plan to start, but I am a HEAVY variable user