Post

2 followers Follow
0
Avatar

Calculation based on catagory selection

I am looking for a calculation that will estimate rehab costs.  I have a category set up with three options $5 - Cosmetic, $8 - Medium, $12 - Full Rehab.  I also have a text field for square footage.  I am wanting a calculation field that will multiply the square footage times the category selection.  Is this possible?

Joey Taylor

Please sign in to leave a comment.

2 comments

0
Avatar

Hello Joey,

sury, that's possible. But cause category and square footage are both in text format, both must be parsed to number first:

var cat = @Your category field;
var cat = cat != null ? cat.replace(/[^0-9]/g,"") : 0;
var cat = Number(cat) || 0;
var sqf = @Your text field;
var sqf = sqf != null ? sqf.replace(/[^0-9,\.]/g,"") : 0;
var sqf = Number(sqf) || 0;
sqf * cat

Replace Your category field and Your text field with the names of the fields. Use a fresh new calculation field. 

Rainer

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

So here is what I put in the calculation field-

var cat = @Estimated Repairs;
var cat = cat != null ? cat.replace(/[^0-9]/g,"") : 0;
var cat = Number(cat) || 0;
var sqf = @House Sq Feet;
var sqf = sqf != null ? sqf.replace(/[^0-9,\.]/g,"") : 0;
var sqf = Number(sqf) || 0;
sqf * cat

But I get a- "Script Error: Type Error: undefined is not a function"

Joey Taylor 0 votes
Comment actions Permalink