Edit Equation in the Total Box for Constant Sums

JacquelineSJacquelineS MA, USACommunity Member Qubie ✭

Edit Equation in the Total Box for Constant Sums

Hi all,

Is there any way to edit the equation of the total box in constant sum questions? For example, instead of the total box showing [X+Y], I'd like it to show [X-Y]. I know I could just have my respondents input a negative number for "Y", but they fill out this survey regularly and have always input a positive number for Y. Right now, I have it as a text entry matrix where the respondents have to manually input the total and it always ends up being a little off.

Thanks in advance!


  • ChiragKChiragK GUJARATCommunity Member Qubie ✭
    edited February 10

    Hello @JacquelineS

    This code should work

    Qualtrics.SurveyEngine.addOnReady(function () {
        var $this = jQuery(this.questionContainer);
        var total, inputVal;
        jQuery(".QuestionBody .SumInput input", $this).on("input", function () {
            total = 0;
            jQuery(".QuestionBody .SumInput input", $this).each(function (i) {
                inputVal = jQuery(this).val();
                if (inputVal && inputVal.trim().length > 0 && !isNaN(inputVal)) {
                    total = i === 0 ? parseFloat(inputVal) : (total - parseFloat(inputVal));
            jQuery(".QuestionBody .SumTotal input", $this).val(total);
  • JacquelineSJacquelineS MA, USACommunity Member Qubie ✭

    This looks amazing and works perfectly for constant sums! @ChiragK do you know of a way to change this for matrix constant sums. I'd love to have 4 statements and 2 scale points with the total being scale point 1 minus scale point 2 for each statement.

  • ChiragKChiragK GUJARATCommunity Member Qubie ✭

    @JacquelineS Can you send the link with this type of question?

Sign In to Comment