Dear all,
I have rows of data with abbreviations of Bachelor programs that I want to fully describe in the pop-up. Therefore I made this arcade expression for each bachelor program:
var txt = Split($feature.Opleiding, '/')
if (IndexOF(txt, 'BA') > -1) {
return 'Bedrijfskunde en agribusiness'
}
Sometimes a row has multiple bachelor programs active (i.e. BA/TA). In the Pop-Up all expressions are active, see screenshot. If the program is not in the dataset, it will not be shown.
This way, both studies will show up, but without a comma or 'and'. So that is why I added this expression (expression/expr0)
if (Find('/', $feature.Opleiding, 0) > -1) {
return ', '
}
However three combinations or more from these studies are also possible. Now I randomly put down the expression somewhere in the pop-up. As you might have guessed the comma sometimes will be placed before the bachelor programs or after...
The question: How could I solve this problem so the comma will be placed in between the corresponding active expressions?
Solved! Go to Solution.
The answer is probably "you can't", at least, not without rewriting some of your expressions, or adding a new expression on top of them.
For your popup to adjust based on what your expressions are returning would be its own expression, and can be handled very nicely with the Concatenate function. Really, though, there's no reason for those expressions to all be separate. Consider the following code:
var rep_dict = {
'BA': 'Bedrijfskunde en agribusiness',
'SE': 'Something Else',
'AT': 'Another Thing'
// and so on
}
var prog_arr = Split($feature.Opleiding, '/')
for(var a in prog_arr){
for(var k in rep_dict){
prog_arr[a] = Replace(prog_arr[a], k, rep_dict[k])
}
}
return Concatenate(prog_arr, ', ')
Running this on a test value of 'SE/AT/BA' returns
Something Else, Another Thing, Bedrijfskunde en agribusiness
The answer is probably "you can't", at least, not without rewriting some of your expressions, or adding a new expression on top of them.
For your popup to adjust based on what your expressions are returning would be its own expression, and can be handled very nicely with the Concatenate function. Really, though, there's no reason for those expressions to all be separate. Consider the following code:
var rep_dict = {
'BA': 'Bedrijfskunde en agribusiness',
'SE': 'Something Else',
'AT': 'Another Thing'
// and so on
}
var prog_arr = Split($feature.Opleiding, '/')
for(var a in prog_arr){
for(var k in rep_dict){
prog_arr[a] = Replace(prog_arr[a], k, rep_dict[k])
}
}
return Concatenate(prog_arr, ', ')
Running this on a test value of 'SE/AT/BA' returns
Something Else, Another Thing, Bedrijfskunde en agribusiness
Hi Josh Carlson,
Of course thanks. I wasn't sure you could make dictionaries in Arcade and this is obviously way cleaner. Thank you very much for the quick reply!