In loop & merge, can I subtract multiple times? | XM Community
Skip to main content

I'm attempting to leverage a survey to create a reimbursement process.
A team member could have as little as one item they need to reimbursed for, or as many as twenty. Q2 in the first block will determine the number of times block two is looped.
What I'd like to be able to do is show the team member their remaining balance as they progress through the survey. I'm new at the math equations, but I've figured out how to get Total - Q3 per block to work but I'm trying to find a way to show the amount left to allocate (if they submit more than 1 item) where it should fall in the loop process.
Block 1
Q1 - what is the total amount you need to reimbursed for?
Q2 - how many items make up the amount to be reimbursed? *** this is what drives the loop of block 2
Block 2
Q3 - Amount spent
Block 3
Q3 - Amount spent

Example Response -
B1 Q1 = $250.00 ($250 total reimbursement)
B1 Q2 = 2 (2 items to be reimbursed for)
B2 Q3_1 = $100.00 (1st item was $100)
At the end of the block, it would show that they have a total of $150 to be balanced/accounted for (this is where I am getting stuck on the display logic)
B3 Q3_2 = $150 (2nd item was $150)
At the end of the block, it would show that they have $0 to be balanced/accounted for.
If I could get super savvy, and not let them proceed unless their final amount = $0 or the sum of all the Amount Spents = the same as the total reimbursement, that would be above and beyond🙃
I've attached an export of the survey showing the things I've tried. I would love any feedback or ideas on how to achieve or improve what I've done so far.
Reimbursement_Process - Attempt.qsf

I haven't looked at your .qsf, but ...
(1) You might want to consider using a constant sum question for Q3 instead of a loop. You can use display logic on the rows so the rows displayed match Q2.
(2) If you use a loop, set embedded data field 'remain' to the answer of Q1 before the loop.
Add JS to the Q3 addOnPageSubmit function to update the value of 'remain' based on the answer to Q3.
Pipe the value of remain on the next page.


Leave a Reply