Calculate average from scale ratings

  • Profile Image
    keman1383
    Asked on October 17, 2014 at 01:45 PM

    Can I use scale rating values to calculate an average in another field? If so, how do I go about doing this? I've included the URL to the form I've built below.

  • Profile Image
    Ben
    Answered on October 17, 2014 at 03:48 PM

    Hi,

    You can calculate the averages using our Form Calculation widget and utilizing its Math functions.

    You can see it all in this jotform here http://form.jotformpro.com/form/42895734839978

    I have used the function that only calculates the scales that were edited. So if 1 out of 4 scales is selected, 1 would be average.

    to show in math it would be

    average = filled_out_scale / 1

    This way it will not do calculations such as (if there are 4 scales in the section)

    average = filled_out_scale / 4

    I think that this is the preferred option, but it is easy to change it if you want it to calculate differently.

    Now from start. To do this we need to place Form Calculation widget on our jotform.

    Its wizard will open, so lets set it up

    You will need to scroll down once you click on the more Math functions to find avgNoZero(). Click it and it will add its code to calculation section.

    Since we have hidden fields we must take this into account and ignore them - they are hidden for a reason :)

    Now we can do that over the Show Advanced Options section by clicking on Ignore Hidden Fields option.

    Almost there now. Just to enter the fields we want to get average from:

    Click Finish :)

    That is it..well at least it is for the first calculation.

    What we need now is to do this for all sections that we want to calculate. The steps are the same so just repeat the steps from above and add the Form Calculations and set them as mentioned. The only difference are the fields that are selected to be calculated.

    My suggestion is to set ignore hidden fields even if you are not hiding any fields in that segment at this point of time because if you do add it in the future it will not work, but this way you are already securing yourself to have it working even then ;)

    Now at the top the jotform that I have given the link to will calculate each section and the average of all sections together at the end.

    You can clone the jotform for closer inspection or just to skip setting everything up, it is up to you :)

    Do let us know how it goes and if this is what you wanted to achieve. Please also let us know if you have any further questions.

    Best Regards,
    Ben

  • Profile Image
    Masalamedia
    Answered on November 23, 2016 at 06:20 PM

    This doesn't work for me. The calc field displays the raw values of each rating field with visible commas. No calculation preformed.

     

    See screenshot at https://www.dropbox.com/s/d9yohk40cmp6nfi/Screenshot%202016-11-23%2015.20.00.png?dl=0

  • Profile Image
    jonathan
    Answered on November 23, 2016 at 08:58 PM

    @Masalamedia

    We will resolve your issue on the thread you created here https://www.jotform.com/answers/996818

    Thank you.