Working with Numbers 💯

(Ryan McGuinness) #1

Our numbers service allows you to perform calculations with input(s) of your choice, this will then allow you to use the result as an output. It can do basic addition, subtraction, multiplication and division as well as higher level functions such as power, range etc

We also have a fantastic tool in our ‘format number’ setting, this will allow you to take any input and apply the formatting you need. You can add decimal points or commas, add symbols such as ‘$’ or ‘%’. This can be particularly useful if you’re integrating with a system that has strict formatting rules i.e. an invoicing system or an ordering system. In particular, companies that deal with customer inputs for monetary values, this would allow you to convert the input into your standard, regardless of comma or decimal point placement.

Use our ‘unformat number’ to remove any formatting from your input. This could be useful for example, if you are collecting contact numbers. A customer might give +1541-754-3010 in your webform, which you’ll pass as the input to your ‘Unformat Number’ action. The output you’ll get from this is 15417543010.

You can also use the “generate random number” action, this does exactly what is says. You can generate random numbers between two set values. So if you want to generate numbers between 1 & 10, the use 1 as your ‘minimum’ value and 10 as your ‘maximum’ value. This could be ideal if you wanted to create a Bot that provides a user with random recipes for example, see our article “Generate a Random Answer” for more information.

(Joe Hatch) #2

Hey Ryan,

On this: We’re currently using a flow that will do some logic calculating for our Commercial Finance leads in FLG.

We use the numbers service to work out a Loan To Value amount for one of the steps which is in Number - Calculate.

We’re using
100 / {{format_property_value.result}} * {{format_debt.result}}

Which returns the % (for example, if the property value is 100,000 and the existing debt is 10,000, it will return 10% LTV).

But the issue is that if there’s no existing debt on the property, it’s trying to calculate 100/100,000* (and then no value). Is it possible to default to 0 or should I convert this to the code service and do something like: (note, I’ve just quickly written this is the post, so probably not right javascript!)

 var formattedValue = inputs.formattedValue;
var formattedDebt = inputs.formattedDebt;
var ltv = calculateLTV(formattedValue, debtAmount);

function debtAmount() {
if (formattedDebt == "") {
return(0)
}
else {
return (formattedDebt)
}
}

function calculateLTV (value, debt){
return 100/value*debt
}
resolve (ltv);
(Ryan McGuinness) #3

Hi Joe,

At present, it isn’t possible to do without code. Seems like you’ve pretty much got it though :slight_smile:

Ryan.