Calculate the total between two date field values and radio button

  • sercanselvi
    Asked on April 22, 2016 at 11:34 AM

    Solved the problem.

  • Welvin Support Team Lead
    Replied on April 22, 2016 at 1:00 PM

    The condition seems to be working now. I guess you've figured this out already. Let us know if you need any further assistance.

    Calculate the total between two date field values and radio button Image 1 Screenshot 20

  • Welvin Support Team Lead
    Replied on April 22, 2016 at 1:01 PM

    I'm sorry, I was assigned here before you modify the thread. It's great to know that you've solved it. Please contact us again if we can help in any way.

  • sercanselvi
    Replied on April 22, 2016 at 3:38 PM

    Hi Welvin,

    Thanks for the quick response. I have a question related the same issue. I solved the problem for "Package A1 - Single" option. If you check-in later you still get the package price and if you check-in earlier price goes up. It also works with "Package A2 - Single".

    I thought I found the right solution but when I use the same method for "Package A2 - Double" and try to check-in later price goes up. Or if I choose some other day and come back to the default date I get the wrong price.

    Can you help me with that?

  • sercanselvi
    Replied on April 22, 2016 at 4:24 PM

    I am trying the same condition with "Package B1 - Single" as well. There is an extra condition that says if "Package B1 - Single" selected and the total cost under 2680 then total cost field needs to show "2680". But if you select "Package B1 - Single" and change the check in date to 25th and come back to 24th then you get 2642 as the last number.

  • Boris
    Replied on April 22, 2016 at 6:14 PM

    As you've edited the original post of this thread, it is not clear which form it is about, and what was the initial query about. You currently have two similar forms, and I'm not sure which of them you are working on - both were last edited today:

    60896091926164, named World Congress 2016 Test

    61126355480149, named Clone of World Congress 2016 Test

    I've checked both forms, and I see that the "Clone" form which was edited last no longer has the issue you have described. Have you indeed resolved the issue you were experiencing?

    I would also like to add that you seem to be using a Form Calculation field, with insert conditions set up to modify its value. This is likely to create conflicts between the calculation (which will calculate to zero) and the insert conditions (which will calculate the value you are looking for).

    The form cannot know which value should take precedence, the calculation or the condition, and it is possible that some submissions will result with the total price being zero. For this reason, I would recommend using a regular Text Box field instead of a Form Calculation field if you will be conditionally insert values into it.

    I hope this helps, please let us know if you need any further assistance. Thank you.

  • sercanselvi
    Replied on April 25, 2016 at 10:59 AM

    Hi Boris,

    Thank you for help and sorry for the confusion. 

    I created the clone form after submitting this problem, just in case if there is no solution I wanted to have a Plan B. I am having problems with the first form (60896091926164, named World Congress 2016 Test).

    What I am trying to do is to have a fixed value for the selected package. If people want to check-in earlier than the expected date or want to stay extra days then I need to charge them extra. The condition I created for "Package A1 - Single" works perfectly.

    If you go and select "Package A1 - Single" you get the right check-in and check-out dates (24-28 October 2016) with the package price (2470).

    Calculate the total between two date field values and radio button Image 1 Screenshot 40

     

    If you want to stay shorter, the package price stays the same (Condition 1).Calculate the total between two date field values and radio button Image 2 Screenshot 51

    If you change your check-in date or check-out date for staying extra then price goes up (Condition 2).

    Calculate the total between two date field values and radio button Image 3 Screenshot 62

    I used the same conditions for the other options, then I saw that these conditions were not working for them.

    Issue 1: The calculation field was showing less than what's in the condition value (fixed package price). 

    Issue 2: When you change the dates and come back to the default date value then you were not getting the default package price.

    I keep the condition for "Package A1 - Single" because it works but removed the rest because they don't work. Can you have a look at it and let me know what is the problem? Is it because there were a lot of conditions?

    This calculation style looks complicated from the back-end (a lot of conditions and background calculations) but I am trying to make it easier for the front-end users.

    ps: I never got "zero" as the total cost.

  • Welvin Support Team Lead
    Replied on April 25, 2016 at 12:48 PM

    Can you give us an example condition that you'd like to add? But when adding the condition, I would suggest trying to select IF ALL so that the condition will only work if all fields in the rules are matched. This would also prevent a conflict when other options are selected. 

    For the Total cost, I noticed that you are using this in the rule, but at the same time, you have it as the target field (condition 1). If you'll be calculating field based on the total, I would suggest adding a new target field. That is to make sure that price will change as soon as you change the options/dates.

    We can help you with this, but please let us know a brief on how you would like to calculate the total between fields.

  • sercanselvi
    Replied on April 25, 2016 at 1:14 PM

    As you can see I have different packages and different pricing for these packages. I added package prices as the calculation values.

    Calculate the total between two date field values and radio button Image 1 Screenshot 20

    When people choose their package total cost shows the field value. Check-in and out dates also come from the background as pre-defined values. So far so good.

    What I need is to charge people extra (depending on their room selection) when they change their defined check-in or check-out dates and want to stay longer. Here I have 4 potential cases, that's why I did not use the "IF ALL" function.

    1- If people only change their check-in date and say that they will arrive earlier than expected but will leave as planned, I need to charge them for extra days.

    2- If people only change the check-out date and say that they will arrive as expected but will leave later, I should be able to charge them.

    3- If people change both in and out dates I need to charge them for these extra days.

    4- If they change in or out dates and claim that they are going to stay shorter than the defined package dates, then the "Total Cost" field needs to show the package price. They shouldn't be able to see a lower price than the package price. That's why I created "Condition 1".

    Do you think if I create a new hidden calculation field that would solve the problem?

  • Huberson
    Replied on April 25, 2016 at 3:22 PM

    If I understand correctly, you want to modify the package price if people choose to stay longer.

    Since the other 4 possibilities are based on the chosen dates, you could set a hidden field with the base price per additional day and use Nights in the Hotel field to perform the calculation with the predefined hidden value (you could set this value either in percentages or fixed) field to get the amount.

    For example, you could have the hidden field set as 2% of the default price for a specific package, then if someone choose an earlier check-in date you calculate the additional day using Nights in the Hotel field, use the base package price to find the amount for the 2% and multiply that by the additional day.

  • sercanselvi
    Replied on April 25, 2016 at 3:43 PM

    Hi Huberson,

    Thanks for the support. That's what I am trying to do. Conditions&calculation work for the first option, when I duplicate them and make the package-based changes then they don't work. Calculation logic and the conditions are the same, it works for option 1 but doesn't work for the rest.

  • Huberson
    Replied on April 25, 2016 at 6:08 PM

    I have made a demo of the above suggestion using a clone of your form.

    Instead of using a single condition block for check-in and check-out changes, I used three block - one for check-in, one for check-out and another for the two possibility ( In case someone modify both date ). And perform the calculation as explained previously.

    The calculation and conditions for all the options should be the same as the screenshot below except the base price and date value that will change according to the option.

    Calculate the total between two date field values and radio button Image 1 Screenshot 20

     

    You can check the clone here: https://form.jotform.com/61157047475963. Or clone it to view the conditions.

    Note that only Package A1 - Single has the conditions applied on the demo. Simply duplicate the conditions then change the options and base value if it works for you.

  • sercanselvi
    Replied on April 26, 2016 at 11:58 AM

    Thanks a lot for your help. I just tested the form. I changed my check-out date from 28 (default value) to 29 and then back to 28th and the cost stayed same with an extra day. Do I need to add one more condition that says if (all) check-in is equal to 24th, check-out is equal to 28 and "Package A1-Single" is selected then calculate the field value by using update/calculate field condition?

     

  • Huberson
    Replied on April 26, 2016 at 12:52 PM

    In that case you will need three conditional block for each date ( check-in, check-out ). One if someone choose before the default date, a second if after and the third if both date are modified.

    I have update the clone to reflect those changes, you can test it to see if it does what you want - https://form.jotform.com/61157047475963.

     

  • sercanselvi
    Replied on April 27, 2016 at 12:12 PM

    Thank you the solution Huberson!

  • Huberson
    Replied on April 27, 2016 at 1:17 PM

    You are welcome!

    Contact us anytime if assistance is needed.