Calculated Fields Form
[resolved] How to use the condition "IF" (3 posts)

  1. rey.abc
    Posted 2 years ago #

    First of all, terrific plugin! I love it, thanks for it, im even considering buying it. Im very new to using it still so im a little confused. Im trying to get the condition IF to work, but i cant do it. I tried looking up at http://wordpress.dwbooster.com/forms/calculated-fields-form but could not find my answer.

    I have two different BMR formulas, one for males and one for females, both very different. It'd be possible to incorporate it into just 1 calculator if i could use the IF condition but i dont know how to do it, this is what i thought would work but did not:

    IF(fieldname5=men, 66 + (6.23*fieldname3) +(12.7*fieldname2) - (6.8*fieldname4), IF(fieldname5=women, 655 + (4.35*fieldname3) + (4.7*fieldname2) - (4.7*fieldname4)))

    Ill write what the fieldname means so you can understand it better:
    Fieldname5=sex, fieldname3=weight, fieldname2=height, fieldname4=age
    Thanks a lot!

    This are the formulas:
    *Men: BMR = 66 + ( 6.23 x weight in pounds ) + ( 12.7 x height in inches ) - ( 6.8 x age in years )

    *Women: BMR = 655 + ( 4.35 x weight in pounds ) + ( 4.7 x height in inches ) - ( 4.7 x age in years )


  2. rey.abc
    Posted 2 years ago #

    Just posting again to say that i actually Solved this. Incase someone in the future has the same question as i did, this is what i did:

    (fieldname5=='men'?66:655) + ((fieldname5=='men'?6.23:4.35)*fieldname3) + ((fieldname5=='men'?12.7:4.7)*fieldname2) - ((fieldname5=='men'?6.8:4.7)*fieldname4)

  3. codepeople
    Plugin Author

    Posted 2 years ago #


    Another possible solution would be:

    return 66+fieldname3*6.23+fieldname2*12.7-fieldname4*6.8;
    return 655+fieldname3*4.35+fieldname2*4.7-fieldname4*4.7;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Calculated Fields Form
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic