How to capture values from "select_multiple" question on another "text" question.

238
3
Jump to solution
02-27-2024 07:06 PM
JoseBarrios1
Occasional Contributor III

Hello Community,

I'm not sure if this function is possible, but I want to capture the values from a 'select_multiple' question in  another text field. The problem is that the choices also include 'Other color,' which  I capture on another text question. I want to capture ALL the selected values from the multiple-choice question except the 'Other' value, and then combine all the values. The final text field will include all the selected values from 'select_multiple' (except 'Other') and the value from the question ${add_other}. (see image). I can't figure out how to concat the list without including "other' as part of the list. Any suggestions?

Thanks,

JB

select.png

Update****************SOLVED

After many attempts, I was able to accomplish the desired outcome. Not the most elegant solution, but it works. The expression checks if 'Other color' is selected in ${colorList}. If it is, it concatenates the part of ${colorList} before and after 'Other color' to exclude it. Otherwise, it keeps ${colorList} unchanged. I combined the final selected list using the 'concat' function in ${allColor}. Here's the final expression in case someone else encounters a similar requirement.  

if(selected(${colorList}, 'Other color'),
concat(
substring-before(${IndOrgCollectDataList}, 'Other color'),
substring-after(${IndOrgCollectDataList}, 'Other color')
),
${colorList}
)

 

Thanks,

JB

1 Solution

Accepted Solutions
JoseBarrios1
Occasional Contributor III

Update****************SOLVED

After many attempts, I was able to accomplish the desired outcome. Not the most elegant solution, but it works. The expression checks if 'Other color' is selected in ${colorList}. If it is, it concatenates the part of ${colorList} before and after 'Other color' to exclude it. Otherwise, it keeps ${colorList} unchanged. I combined the final selected list using the 'concat' function in ${allColor}. Here's the final expression in case someone else encounters a similar requirement.  

if(selected(${colorList}, 'Other color'),
concat(
substring-before(${IndOrgCollectDataList}, 'Other color'),
substring-after(${IndOrgCollectDataList}, 'Other color')
),
${colorList}
)

 

Thanks,

JB

View solution in original post

0 Kudos
3 Replies
JenniferAcunto
Esri Regular Contributor

You can use the selected-at function to query each selection made to see if it is 'other' and use that in an if statement to determine if you want to use that selection in a concat. In your example, you have 4 options. This means someone could have chosen other as their 1st, 2nd, 3rd, or 4th option. We will need to check each position. So if you have 5 options, you will need to do this 5 times, if you have 3 options, only 3, etc. 

Then there is the comma problem. You have to add those manually to your concat, but if they only select 2 choices, you will end up with a bunch of extra commas at the end: red, blue,,,. So to get around that, I added a inner concat statement to only add a comma if a selection was made. 

if(selected(${colors}, 'other'), concat(if(selected-at(${colors}, 0) = 'other' or selected-at(${colors}, 0) = '', '', concat(selected-at(${colors}, 0), ', ')), 
if(selected-at(${colors}, 1) = 'other' or selected-at(${colors}, 1) = '', '', concat(selected-at(${colors}, 1), ', ')),
if(selected-at(${colors}, 2) = 'other' or selected-at(${colors}, 2) = '', '', concat(selected-at(${colors}, 2), ', ')),
if(selected-at(${colors}, 3) = 'other' or selected-at(${colors}, 3) = '', '', concat(selected-at(${colors}, 3), ', ')), ${colors_other}), ${colors})

 

- Jen
0 Kudos
JoseBarrios1
Occasional Contributor III

Hi Jennifer,

Thank you for your suggestion. What I posted was a simple example to represent what I'm trying to accomplish. Your approach could be a solution to a small list, however my dynamic list (cascading) has between 6 to 28 values  that depends  on the previous selection. Although not impossible, it would be very diffucult and impractical to build an expression that accounts for all selections. I wish there were a way to concat all values except the string containing "Other". 

JB

0 Kudos
JoseBarrios1
Occasional Contributor III

Update****************SOLVED

After many attempts, I was able to accomplish the desired outcome. Not the most elegant solution, but it works. The expression checks if 'Other color' is selected in ${colorList}. If it is, it concatenates the part of ${colorList} before and after 'Other color' to exclude it. Otherwise, it keeps ${colorList} unchanged. I combined the final selected list using the 'concat' function in ${allColor}. Here's the final expression in case someone else encounters a similar requirement.  

if(selected(${colorList}, 'Other color'),
concat(
substring-before(${IndOrgCollectDataList}, 'Other color'),
substring-after(${IndOrgCollectDataList}, 'Other color')
),
${colorList}
)

 

Thanks,

JB

0 Kudos