You are viewing limited content. For full access, please sign in.

Discussion

Discussion

how do i prevent a division of zero on a form calculation when the field has no value because it is hidden and should be ignored?

posted on August 16, 2021

I have a field (BMI) that calculates the BMI for annual physical forms that are submitted.  The issue I'm having is that the values used to calculate the BMI are blank because they are only visible and entered if the form submitted is an annual physical form.  The other forms (colonoscopy, pap, prostate, mammo) do not have these values, so the BMI field is hidden and then I get a division by 0 because I don't want any value in that field that would be carried over to the template.

IS there a way to disable a form calculation if the field is hidden?

 

Thanks and have a great happy week!!!

 

0 0
replied on August 16, 2021

Nice!  Just really getting into calculatiksons and lovin' it!  

Thanks Jared!!  TTFN :)

1 0
replied on August 16, 2021

You could wrap it in an if statement

=if(BMI="","",YourFormula)

=if(BMI=0,"",YourFormula)

Saying if BMI is blank (or =0 in the second example), this field should be blank. Otherwise, do the formula you had. 

1 0
replied on August 18, 2021

Hi again :)  I'm getting a syntax error.  What am I missing?  Please and thank you!!

 

=IF(BMI_Calc_Number="","",MULT(DIV(weight,MULT(height,height)),703),
IF(BMI_Calc_Number=0,"",MULT(DIV(weight,MULT(height,height)),703))

0 0
replied on August 18, 2021

The if statements provided by Jared are 2 separate statements and not nested.  You need to nest the second if statement into the first.

An If statement has 3 parts, (Condition, IF True Value, If False Value)

To nest the second If statement, it goes into the If False Value area of the first If statement.

=IF(BMI_Calc_Number="","",IF(BMI_Calc_Number=0,"",MULT(DIV(weight,MULT(height,height)),703))

 

1 0
replied on August 18, 2021

Thanks Bert.  This is my first IF with Forms.  Still getting syntax error.  It looked like it was short a pesky paren so I closed the last ) and still getting error:  
=IF(BMI_Calc_Number="","",IF(BMI_Calc_Number=0,"",MULT(DIV(weight,MULT(height,height)),703)))

 

sad

 

0 0
replied on August 18, 2021

Yep, it looks like I missed a ")" and just adding it to the end puts it in the wrong spot.

=IF(BMI_Calc_Number="","",IF(BMI_Calc_Number=0,"",MULT(DIV(weight,MULT(height,height))),703))

 

replied on August 18, 2021

You may try an IF statement that uses Greater Than 0 instead of the ="" and =0

 

IF(BMI_Calc_Number>0,MULT(DIV(weight,MULT(height,height)),703),"")

0 0
replied on August 18, 2021 Show version history

getting error:  

0 0
replied on August 18, 2021

Oh you have a circular reference, you can't use a field variable in its own calculation. You need to put this formula in another field so 

IF (BMI: is blank, leave that field blank, otherwise fill it with your formula)

1 0
replied on August 18, 2021

ahhhh   OK.  That all makes sense now.  Sooo many lessons learned.  Thank you allll so very much!!!

0 0
replied on August 19, 2021

I just wanted to thank you all again.  I love laserfiche more and more each day!!  I got the code in correctly now with the help of you both and learned lots along the way :)  TTFN!!

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.