Field won't calculate

330
2
09-12-2019 06:48 AM
JasonCyphers
Occasional Contributor III

I have a form that captures the costs to install a pipe by boring it, vs. more expensive options.  So, it basically looks like this:

Crew Time:

____________

Equipment Time:

____________

Bore Cost:

(${crew_time}*125)+(${equipment_time}*50)

Alternate Install Method:

____________

Alt Method Cost:

if(selected(${alt_method},'Plow'),((${crew_time}*125)+(${equipment_time}*50)*2),if(selected(${alt_method},'Trench),((${crew_time}*125)+(${equipment_time}*50)*5),0))

Cost Savings:

${alt_method_cost}-${bore_cost}

I'm having an issue with the cost savings calculation.  I'm guessing the cost savings calculation is being performed as soon as the Bore Cost field is getting calculated and populated, because the value always seems to come back as negative whatever the bore cost is.  It doesn't appear to be picking up the alt method cost.

I've even tried adding another question after the alt method cost that the cost savings calculation would be dependent on before it executed the calculation - something like "if work_complete is yes, perform the calculation, if work_complete is no, perform the calculation; otherwise enter 0 as the value".  This keeps a value of 0 in the cost savings field until I check yes or no for the new question, but even then, it's not performing the calculation, it's just entering a negative bore cost value...it still doesn't appear to see the value of the alt method cost.

Any ideas/solutions?  

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

I see a ' missing after Trench
if(selected(${alt_method},'Plow'),((${crew_time}*125)+(${equipment_time}*50)*2),if(selected(${alt_method},'Trench),((${crew_time}*125)+(${equipment_time}*50)*5),0))

My other guess would be that once of the fields is changing to string.  Try using the bind column to make sure it is a int or decimal.

0 Kudos
JasonCyphers
Occasional Contributor III

Thanks for the comment.  Those formulas I just typed out as a sample, the formulas in the actual xml are correct; otherwise I'd get an error when trying to save it.).

Also, all the fields that need to be numbers are in fact numbers.

0 Kudos