# Calculate scores based on survey questions and assign highest score

Community Member Qubie ✭

# Calculate scores based on survey questions and assign highest score

Hi - I'm trying to automate some segmentation work that gets done based on survey questions. Basically, I have a number of segments, and the score for each one is calculated by multiplying the responses to specific questions by different values. Then, whichever segment has the highest score is the segment that the user is assigned to.

I found this question that was previously asked that's quite similar, bu I'm not sure how to set up the calculations - would this be a formula variable or is there any way to set the calculation up before any responses are recorded?

Also curious if anyone might know how to do this in Javascript.

Thanks!

• MedellínCommunity Member, Qualtrics Partner, XMPN Member, XMPN Champion Superuser ✭✭✭✭

Hi!!

i have done this with math operations in the embedded data, with this i assign a result for each of the segments. and then i create multiple branches to give a value to the final segment.

The branch would say: if segment 1 is greater than the piped text for sgement 2

final segment= segment 1

• MedellínCommunity Member, Qualtrics Partner, XMPN Member, XMPN Champion Superuser ✭✭✭✭

Hi! I believe you can do that using the piped text for the second option!

• Community Member - Trial User Wizard ✭✭✭✭✭

We use Math operation in this scenario. Assuming all your questions included in calculation are force response you can use selected choice code in the formula. Once all the segment value is calculated use the method mentioned in the post you have mentioned in the question.

Also, similarly we can also use JS in this scenario, like capturing all selected choice code in variable and then doing calculations on it. The results are stored in embedded data.

• Community Member Qubie ✭

@rondev Any chance you could walk me through the JS for this? I'm very new to this and not quite sure how to do it.

Unfortunately they're not all force response, but if one particular field is missing, I'd just want the segment to be NA.

Thank you both for your responses!

• Community Member Qubie ✭

Hi again @ana_velez_voce - I've assigned each of my segments, and now I'm struggling a bit with the second part. Are you able to compare two objects like that? When I select if segment1 is greater than, the comparison it gives me has to be typed in - not sure how to compare it to another object