Good afternoon, I am running into an issue when labeling on the new map viewer. For some reason, my arcade script is adding zeros onto a currency field. Below is my script. Can anyone advise me on what I may be doing wrong. Thanks. Below is my scripts
if ($feature.Change > 0 ) {return Text($feature["Change"], '$##,###,###' + ' - '+ Round(($feature["F__Change"])*100,2)+ "%")}
This turns a value of $1,900 into $190,000
Solved! Go to Solution.
Just to follow up, it was a combination of issues.
It's lower down in the Function Reference page, but you can see that when "%" appears in the formatting string, it will multiply by 100 and format as a percentage.
By moving the parenthesis, the "%" is no longer in the formatting string, and the function won't trigger the multiplying by 100.
Does the expression evaluate properly in other contexts, like in Pro or a Dashboard? At a glance, it looks like you're missing a closing parenthesis after your text formatting string.
return Text($feature["Change"], '$##,###,###' +...
I'm only working with hard-coded variables, since I don't have a layer handy to test this on, but I can't replicate the issue:
What you might try, though, is to establish variables and use template literals for your string, and see if that behaves any differently. At the very least, it's a nicer way of writing strings with multiple parts.
var c = $feature["Change"];
var f = $feature["F__Change"];
if (c > 0 ) {
return `${Text(c, '$##,###,###')} - ${Round(f * 100, 2)}%`
}
Just to follow up, it was a combination of issues.
It's lower down in the Function Reference page, but you can see that when "%" appears in the formatting string, it will multiply by 100 and format as a percentage.
By moving the parenthesis, the "%" is no longer in the formatting string, and the function won't trigger the multiplying by 100.