Identify the variable with the maximum value | XM Community
Skip to main content
I need to have respondents assigned to an defined customer segment for needed survey quotas. The segment the respondent belongs in is determined by a series of calculations driven from answers to a matrix question. I currently have all the calculations set up and working correctly. The calculations determine the value of 5 variables (one for each possible segment) set up as embedded data; Seg1_log, Seg2_log, Seg3_log, Seg4_log, & Seg5_log.



I'm not a programmer so this is where I'm stuck. I need to compare these 5 variables to determine which has the largest value and return a 1, 2, 3, 4, or 5 based on the largest value. Ideally the new variable would be called 'segment' and would have the number 1, 2, 3, 4, or 5 assigned to it. From there I can pick up the new variable ('segment') and use it for the survey quotas. I'm assuming I need to use JavaScript but that's way out of my league. Any help would be appreciated.
You can do this with a bunch of branching, if you're not feeling up to JS.



Set the branch up like:

Seg1_log is greater than Seg2_log AND Seg1_log is greater than Seg3_log AND Seg1_log is greater than Seg4_log AND Seg1_log is greater than Seg5_log

Then set Embeddeddata Segment = 1



Repeat for all the rest SegX_logs.
Thanks Jen!

Leave a Reply