Title: Calculation Help
Last modified: August 31, 2016

---

# Calculation Help

 *  Resolved [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/)
 * Hello! First of all I want to thank you for this awesome plugin!
 * But anyway I need your help with the equation.
 * [http://puu.sh/pfeFY/4f9ad58e22.png](http://puu.sh/pfeFY/4f9ad58e22.png)
 * In the screenshot above I have illustrated how the price is calculated.
 * “715” is the default value(price) and is being multiplied to different coefficients
   from the other boxes(fieldnames).
 * The strokes with arrows are dependencies.
 * I hope that you understand how the graph is organized.
 * Thank you in advance.
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/calculation-help-1/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/calculation-help-1/page/2/?output_format=md)

 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444280)
 * My example is a little bit complex, but I hope you can give me a solution.
 * Regards, Andrei.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444315)
 * Hi,
 * Your screenshot illustrates the way your dependencies are defined but not the
   structure of the equations.
 * If you need a custom coding service, do not hesitate in contact me through my
   private support page with a detailed description of your project (not only the
   screenshot)
 * [http://cff.dwbooster.com/customization](http://cff.dwbooster.com/customization)
 * Best regards.
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444322)
 * Hi, thank you for reply!
 * I was hoping that you understand the structure of equations.
 * Can I explain you how a price is calculated?
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444329)
 * Example 1:
    We select the first box from the top from fieldname1. 715 * 0.7(fieldname2)*
   1.4(fieldname7) * 0.9(fieldname8) * 1.0(fieldname10) * 1.0(fieldname11) * 1.2(
   fieldname12) = final price.
 * Example 2:
    We select the third box from the top from fieldname1. 715 * 0.9(fieldname4)*
   1.0(fieldname7) * 1.5(fieldname8) * 1.2(fieldname9) = final price.
 * Example 3:
    We select the last box from the top from fieldname1. 715 * 1.5(fieldname6)*
   0.9(fieldname7) * 0.9(fieldname8) * 1.2(fieldname10) = final price.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444330)
 * Hi,
 * I will try to explain the process with an example. If the values of the choices
   in the fieldname1 are: first choice ‘A’, second choice ‘B’, and the third choice‘
   C’, the equation should use conditional statements, as follows:
 *     ```
       (function(){
       if(fieldname1=='A') return 715*0.7*fieldname2*1.4*fieldname7*0.9*fieldname8* 1.0*fieldname10*1.0*fieldname11*1.2*fieldname12;
   
       if(fieldname1=='B') return 715*0.9*fieldname4*1.0*fieldname7*1.5*fieldname8*1.2*fieldname9;
   
       if(fieldname1=='C') return 715*1.5*fieldname6*0.9*fieldname7*0.9*fieldname8*1.2*fieldname10;
       })()
       ```
   
 * Be sure to use all multiplication symbols, for example:
 * 1.2(fieldname10) is incorrect, the correct is: 1.2*fieldname10
 * Best regards.
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444334)
 * Thank you very much, I will try now and see if it works.
 * 1.2(fieldname10) – I mentioned the coefficient 1.2 from fieldname10(in my case
   the dropdown).
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444339)
 * One more question, in the equation field I need to insert all the possible examples?
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444344)
 * I think your examples are correct, but they are only working for that concrete
   scenarios.
 * In my case I need a general formula how to multiply different coefficients from
   differents fieldnames(dropdowns).
 * [http://puu.sh/pfmEy/16215bf30b.png](http://puu.sh/pfmEy/16215bf30b.png)
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444353)
 * Hi,
 * I’m not sure about your form’s structure, however, if the values to use in the
   equations are the values of the choices of fields, you simply should multiply
   the fields in the form, and won’t be needed to use conditional statements.
 * Best regards.
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444366)
 * Mate I have a problem, I have added a formula in the equation field that is working
   for a part of my calculator:
 * prec((fieldname2*fieldname4*fieldname9*fieldname10*fieldname16),2)
 * Now how can I add another formula in the same equation field?
 * [http://puu.sh/pftbt/a9b6b5b425.png](http://puu.sh/pftbt/a9b6b5b425.png)
 * In my screenshot you see 2 formulas but now the calculator is not working, if
   I leave only 1 formula everything is working.
 * Thank you in advance.
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444367)
 * Buddy I have a little problem:
 * [http://puu.sh/pftbt/a9b6b5b425.png](http://puu.sh/pftbt/a9b6b5b425.png)
 * In the screenshot you can see 2 formulas, but something is not working properly,
   if I delete the last formula, everything is working fine.
 * I think that I am missing something that is causing errors between the equations.
 * Thank you in advance.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444378)
 * Hi,
 * If the equation associated to a calculated field has separated operations, you
   should use a conditional statement to select the operations to apply, and return
   the result:
 *     ```
       (function(){
       if(...) return PREC(fieldname2*fieldname4*fieldname9*fieldname10*fieldname16,2);
       return PREC(fieldname2*fieldname4*fieldname9*fieldname10*fieldname14,2);
       })()
       ```
   
 * of course, in the previous equation should be replaced the symbols … by the condition
   to check.
 * Best regards.
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444440)
 * [http://puu.sh/pghRz/24ccf096a8.png](http://puu.sh/pghRz/24ccf096a8.png)
 * (function(){
    return PREC(fieldname2*fieldname4*fieldname9*fieldname10*fieldname16,2);
   return PREC(fieldname2*fieldname4*fieldname9*fieldname10*fieldname12,2); return
   PREC(fieldname2*fieldname4*fieldname9*fieldname10*fieldname13,2); })()
 * I have a little problem, in the 2nd and 3rd equation the fieldname12 and fieldname13
   are not being multiplied.
 * Fieldname11 and Fieldname14 I do not include as there choices have 1.0 coefficient.
 * The first equation is working properly, but the other ones are being multiplied
   till Fieldname10.
 * I do not understand where is my mistake here.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444446)
 * Hi,
 * In javascript, the instructions below a “return” statement are not reached, so,
   your function is returning in the first “return” statement.
 * Could you describe your equation, please?
 * For example, if the fields: fieldname16, fieldname12, and fieldname13 are dependent
   fields, if they are not active, their values are zero, in whose case the equation
   can be implemented simply as follows:
 * `PREC(fieldname2*fieldname4*fieldname9*fieldname10*(fieldname16+fieldname12+fieldname13),
   2)`
 * and that’s all.
 * Best regards.
 *  Thread Starter [andres.t2005](https://wordpress.org/support/users/andrest2005/)
 * (@andrest2005)
 * [10 years ago](https://wordpress.org/support/topic/calculation-help-1/#post-7444447)
 * Fieldname4, Fieldname5, Fieldname6, Fieldname7, Fieldname8 are dependent on Fieldname2.
 * Fieldname16(hidden) is dependent on second value(choice) from Fieldname10.
 * Fieldname14 is dependent on first value(choice) from Fieldname10.
 * Fieldname11 is dependent on first value(choice) from Fieldname14.
 * Fieldname12 is dependent on first value(choice) from Fieldname11.
 * Fieldname13 is dependent on second value(choice) from Fieldname11.

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/calculation-help-1/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/calculation-help-1/page/2/?output_format=md)

The topic ‘Calculation Help’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 16 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/calculation-help-1/page/2/#post-7444448)
 * Status: resolved