Constant Sum - add leading zero to resulting sum, if sum < 10 | XM Community
Skip to main content
Solved

Constant Sum - add leading zero to resulting sum, if sum < 10

  • January 20, 2022
  • 1 reply
  • 52 views

Hi everyone!
I would like to display and save the result (i.e., the sum) of a constant sum question in a way that always two digits are displayed/saved. I already added a range requirement (0-99).
But for sums < 9, a leading zero should be added. For example: If the resulting sum is 8, it should be displayed (also in piped text) and saved as "08" not as "8".
Is there a way to do this? Thank you for your help.
Best

Best answer by Tom_1842

Hi there,
I think this can be accomplished via the survey flow and branch logic. Have the respondent answer the Constant Sum and then save the total as embedded data in the Survey Flow. Then, if that total value is less than or equal to 9, add a 0 to the beginning of it, like in the below:
ConstantSum_2digit.png

1 reply

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • Answer
  • February 11, 2022

Hi there,
I think this can be accomplished via the survey flow and branch logic. Have the respondent answer the Constant Sum and then save the total as embedded data in the Survey Flow. Then, if that total value is less than or equal to 9, add a 0 to the beginning of it, like in the below:
ConstantSum_2digit.png