Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Calculation of pass-in field

Hi,

We are trying to calculate one pass-in field based on another pass-in field. For example:

PID = pass-in field
high = new pass-in field
high = x * PID + y.

While we can also save the new variable "high" as a "normal" variable, it is important that we can pass the information "high" (with the right calculation) back to our panel provider. Do you know how we can do this?
asked Nov 9, 2021 by Yordanka (220 points)

2 Answers

0 votes
Just a couple of friendly reminders ...

1/ Ensure PID is a number.
2/ There is a numerical limit on the password field (something like 999,999,999), so be careful as to the type of numerical ranges you are dealing with.

You can pass out your calculated variable "high" via a termination link simply by adding something like "?ID=[%high%]" to the end of the panel termination link.

Note: In my example, "ID" could be called something else with your panel provider, so check in with them as to what variable name they want to pass "high" out as.

Here is an example of a panel provider termination link I used recently ...

https://[blah blah blah]?ID=[%PW%], where "PW" was my password field I was passing back to the panel provider which they called "ID".
answered Nov 9, 2021 by Paul Moon Platinum (97,470 points)
Hi Paul, thanks for your answer. We are not worried about the pass-on thing, but about the calculation. To be more specific our question is: How and where do we calculate the high-variable? How do we refer to the pass-in field? (PID)
OK, apologies. I thought it was the passing out task you had issues with.

You can create a pass-in field called "high". Define the data type as a whole number. I am assuming the result will always be a whole number. Is that correct?

I am assuming "high" is not a reserved word within Sawtooth Software? If it is, name it as something else.

We can use the SetValue function to save the calculated value in to "high".

Place this SSI Script in to the footer of an appropriate question (one that is never skipped) ...
[%SetValue(high,((x*PID)+y))%]

I also assume "x" and "y" are numerical variables within your survey?

Give it a test drive ...
This task can also be completed using a free format hidden variable. I personally prefer using SetValue.
0 votes
You don't need to save the high security code, right?  You just have to calculate it in the outgoing link?

Since the PID values are very large, add them as a pass-in field and set them to text (numeric only supports up to 999,999,999).

Then in the outgoing link, you would have high=[%(StringToNumber(PID) * x) + y%]
answered Nov 9, 2021 by Brian McEwan Platinum Sawtooth Software, Inc. (55,820 points)
Brian, that certainly works. I do like to save it to the data file just in case any queries surface later on from the panel or from yourselves.

Thanks.
...