I am trying to generate a random amount of money to appear in one of my survey questions. I want the random amount to allow for both dollars and cents (i.e., $0.10, $1.25, $10.50, etc.).
I have not been able to figure out how to use the random number generator available in Qualtrics' piped text menu to accomplish this. "$e{ round ( rand://float/0.05:1.50 , 2 ) }" results in "{Invalid Expression}" once evaluated in the survey flow. I have tried some other tweaks, but have not yet gotten it to work the way I want it to.
Could someone help me figure out what I am doing wrong, and how to get the result I want?
Page 1 / 1
You can't use rand in a math expression. Do it in two steps in the survey flow:
```
rand = ${rand://float/0.05:1.50}
rand = $e{ round ( e://Field/rand , 2 ) }
```
```
rand = ${rand://float/0.05:1.50}
rand = $e{ round ( e://Field/rand , 2 ) }
```
@TomG awesome, that works! Thanks!
Follow-up question: the rounding function seems to not preserve trailing zeroes when they appear (i.e., $0.60 presents as "$0.6"). Is there anything I can do to preserve the trailing zeroes?
Follow-up question: the rounding function seems to not preserve trailing zeroes when they appear (i.e., $0.60 presents as "$0.6"). Is there anything I can do to preserve the trailing zeroes?
> @drmiller1220 said:
> @TomG awesome, that works! Thanks!
>
> Follow-up question: the rounding function seems to not preserve trailing zeroes when they appear (i.e., $0.60 presents as "$0.6"). Is there anything I can do to preserve the trailing zeroes?
Unfortunately, there isn't a way to format the number using a math expression. You would have to use JavaScript to format.
> @TomG awesome, that works! Thanks!
>
> Follow-up question: the rounding function seems to not preserve trailing zeroes when they appear (i.e., $0.60 presents as "$0.6"). Is there anything I can do to preserve the trailing zeroes?
Unfortunately, there isn't a way to format the number using a math expression. You would have to use JavaScript to format.
@TomG thanks for letting me know.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.