FAQ: How can I use handlebars to divide, multiply, then generate a percentage value?

Question: I’m trying to replicate an Excel formula of =(((AQ2-S2)/AQ2)*100)&"%", where AQ2 is the “Retail” column and S2 is the “Price per” column in the CSV file. I need to subtract Price per from Retail, then divide by Retail, then multiply that quotient by 100 (to get the percentage) and add the “%” symbol.

For example: Retail is 100 and Price per is 75, so the formula would be ((125 - 93.75)/125)*100, evaluating to 25%. How can I do this in Flow Builder?

Answer: Using handlebars, you’ll need to reference the column names because integrator.io converts export data to JSON. Thus, with a "Retail" value of "125" and a "Price per" value of "93.75", you would use the following handlebars formula:

{{multiply (divide (subtract Retail [Price Per]) Retail) "100"}}%

This is a nested handlebar expression, so it starts with the expression inside the parenthesis. The logic here is to subtract the Price Per from the Retail, then divide by the Retail, then multiply by 100 and add the percent symbol.

We’ve got a lot of great information on handlebar expressions in our Help Center, or search this community to learn how to solve handlebars questions other customers are asking. Let us know if you have other handlebars questions so we can continue to improve our documentation. Thank you!