Add and Substraction Question | XM Community
Skip to main content
Solved

Add and Substraction Question

  • January 19, 2025
  • 10 replies
  • 60 views

Forum|alt.badge.img+3
  • Level 2 ●●
  • 17 replies

Hello everyone, I want to add two embedded data. One of the embedded data is a fixed number and the other is the addition of the income from the tasks. I can see the mathematical additon result in console, but not on the qualtrics page. I did not understand why it’s happening. Could someone help me with that?

Thank you in advance.

Best.

 

Best answer by jbk

Is this question and Embedded are in the same branch. If its,  move the embedded data and Total income calculation after the branch.

10 replies

  • Level 4 ●●●●
  • 275 replies
  • January 20, 2025

can you please be more clear?

What I understood is, you can see the result but not how or where the calculation is, am I right?


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 17 replies
  • January 20, 2025

can you please be more clear?

What I understood is, you can see the result but not how or where the calculation is, am I right?

When I press F12, I see that the two numbers I want to add are added correctly. However, this operation does not display on the qualtrics screen.


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 17 replies
  • January 20, 2025

As you can see.


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 17 replies
  • January 20, 2025

I created an embedded data for it. But not working.


Forum|alt.badge.img+21
  • 319 replies
  • January 20, 2025

I created an embedded data for it. But not working.

You need to follow Math Operations.

I think you forgot about spacing and there seems to be incorrect brackets.

try $e{ e://Field/Total_ECU + e://Field/Guaranteed_Payment }


  • Level 4 ●●●●
  • 275 replies
  • January 20, 2025

I created an embedded data for it. But not working.

Make sure Guranteed_payment embedded data is set to number. Under options you can set it. And ensure the syntax is correct for total income.

 


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 17 replies
  • January 20, 2025

I created an embedded data for it. But not working.

You need to follow Math Operations.

I think you forgot about spacing and there seems to be incorrect brackets.

try $e{ e://Field/Total_ECU + e://Field/Guaranteed_Payment }

I tried it but did not work. Thank you.


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 17 replies
  • January 20, 2025

I created an embedded data for it. But not working.

Make sure Guranteed_payment embedded data is set to number. Under options you can set it. And ensure the syntax is correct for total income.

 

I set the embedded data as number but it still didn't work. This is the code I use for it: 

Qualtrics.SurveyEngine.addOnload(function() {

    var guaranteedPayment = parseInt("${e://Field/Guaranteed_Payment}");

    var totalECU = parseInt("${e://Field/Total_ECU}");

   

    console.log("Guaranteed_Payment:", guaranteedPayment);

    console.log("Total_ECU:", totalECU);

   

    if (isNaN(guaranteedPayment) || isNaN(totalECU)) {

        console.error("Error: Embedded data values are not valid numbers.");

    } else {

        var totalIncome = guaranteedPayment + totalECU;

       

        Qualtrics.SurveyEngine.setEmbeddedData("Total_Income", totalIncome);

        console.log("Total Income saved:", totalIncome);

    }

});


  • Level 4 ●●●●
  • 275 replies
  • Answer
  • January 20, 2025

Is this question and Embedded are in the same branch. If its,  move the embedded data and Total income calculation after the branch.


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • 17 replies
  • January 21, 2025

Is this question and Embedded are in the same branch. If its,  move the embedded data and Total income calculation after the branch.

Thank you. Solved it.