Change calculation values depending on other field selection.

  • Profile Image
    Asked on August 21, 2016 at 12:06 AM

    Is it possible for an if statement in the form calculator? 


    I know i can do if's in conditions, but this doesn't work cleanly as I need it to. 


    So, I'm going to ask users the square footage of a home. The cost of services varies based on the size of the home. 


    The price I'm trying to calculate is based on a dropdown. I know how to set values on a drop down, but I can't figure out how to change the values of a dropdown based on a number inserted previously without creating a bunch of hidden dropdowns for each combination (and thus over complicating my database). 

  • Profile Image
    Answered on August 21, 2016 at 04:08 AM

    Hello psllcom,

    If I'm understanding it correctly, you would like to set a condition on a form calculation. By default, this is possible. But I'm a bit confused with what you wish to achieve. Do you have an example of a scenario so for us to be able to formulate the condition?

    Regarding the dropdown, it's not possible to make it variable. Dropdown values are static, so your option here is to have a number of dropdown fields and set it to appear after a matching condition. May we know as well how the dropdown can be associated to the form calculation and the condition set to it?

    Looking forward to your response.


  • Profile Image
    Answered on August 21, 2016 at 11:57 AM

    So, if a user enters 1500 sqft, the price of the photoshoot options would be different than if someone entered 3500 sqft feet.


    Currently, it's a radio but I've been switching from Radio to Dropbox as a way to experiment and try to get this to work. 


  • Profile Image
    Answered on August 21, 2016 at 03:46 PM

    To my understanding of what you would like to happen, you would want to change the Calculation Values of the radio button field, "Photoshoot Options"

    depending on the value entered in the "Square Footage" number field

    is that correct?

    Also, to my understanding, since you will be using calculation values for the radio field, the value is going to be used to another calculation, correct? 

    If this is correct, then, may I just ask, are the values you need as an output from the radio button, "Photoshoot Options", doesn't have any correlation?

    Let's say, if the value entered on the "Square Footage" field is 1500 sqft., then the calculation values of the "Photoshoot Options" should be 2, 5, 6, and 1, respectively. But if it is 3500 sqft., the calculation values should be 14, 27, 12, and 1, respectively. 

    You see, you can set default calculation values for each option in the "Photoshoot Options" that is related to the desired output base on the value entered in the "Square Footage" number field.

    Right now, for example, I'm thinking of having 1, 1, 1, and 1, respectively.

    Then, everything is going to be manipulated and computed in the condition to the output field("Quote") of the computation.

    Note: I see that you used the Form Calculation widget for your calculation. With the workaround I mentioned above, we just need to use a regular textbox field where the output from the calculation in the condition will be shown.

    Scenario: The value entered in the "Square Footage" number field is 1500 AND the selected option of the "Photoshoot Options" radio field is "Mini Shoot". 

    Having the calculation values 1, 1, 1, and 1, respectively, for the "Photoshoot Options" but the desired output 6 because calculation values should be 2, 5, 6, and 1, I will do what shown in the image below to get the value 6 as the value for "Mini Shoot" if the "Square Footage" is 1500.

    I understand that you have a lot of radio button fields, checkbox fields, and/or drop-down fields used to calculate for your "Quote" and the workaround I mentioned above may require you to create several conditions for each combination of selections, however, this is just a suggestion because you don't want to create a bunch of hidden fields on your form that as you have said may complicate your database.

    Below is a sample form I have created that is based on the workaround above. It only has two rules available for the "Square Footage", less than 2000 and 2000 and above.

    Notice the value of "Quote" changes with each option depending on the value entered in the "Square Footage" if it is less than 2000 or 2000 and above.

    Please feel free to clone the form from its URL so you can inspect it.

    I hope this helps. If, in any case, you have questions with any of the instructions given above, please feel free to contact us anytime and we will be glad to help you. Thank you.

    Thank you.

  • Profile Image
    Answered on August 21, 2016 at 05:57 PM

    I think this is exactly what I was looking to do!! I'll have to spend some time setting up all of my prices, so I'll update if I have any problems. As of now, this looks perfect! Thanks!!!! 

  • Profile Image
    Answered on August 21, 2016 at 06:44 PM

    On behalf of my colleague, you are welcome! Open a new thread if you need anything else. :-)