In my survey, first I set a couple of Embedded Data for testing, MondayAM and MondayPM:
I have then a simple matrix in Question 1 that accepts numeric values only (see screenshot):
E.g. 'Monday - AM' can be either 0 or anything <> 0
I added the following Java code in Question 1:
Qualtrics.SurveyEngine.addOnload(function()
{
if
("${q://QID1/ChoiceNumericEntryValue/1/1}" == "0")
{Qualtrics.SurveyEngine.setEmbeddedData("MondayAM", 0)}
else if
("${q://QID1/ChoiceNumericEntryValue/1/1}" != "0")
{Qualtrics.SurveyEngine.setEmbeddedData("MondayAM", 4)}
});
In Question 2, field ${e://Field/MondayAM} should display 0 when the q://QID1/ChoiceNumericEntryValue/1/1 value is 0, 4 otherwise.
Guess what? It does exactly the opposite; it returns 4 when 0 or no values are entered (default 0), 0 when I entered a value (e.g. 11).
The ultimate goal is to have the total hours by week, adding 4 hours for each slot populated by values <> 0.
What am I doing wrong?
Thanks.
If/else condition somehow works, but it returns exactly the opposite of what I want (!!!)
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

I added the code to Question 2:
... and I get the error when I Save it:
I need a vacation! 😁
Is it maybe possible that it calculates the values in the Total column as well?