Arcade's Round function giving inconsistent results in AGOL pop-up

04-13-2020 11:34 AM
Regular Contributor

I've pulled the Unacast web service into an AGOL web map for our coronavirus site. For part of the display in my pop-up, I have this custom Arcade expression to convert the values in the difference field to a positive number and then display the percentages with a max of two decimals:

var travelpercent = Abs($feature["daily_distance_diff"])
return (round(travelpercent, 2)*100) + '%'‍‍

However, the results in my pop-ups are inconsistent. In one spot, it looks great:

But in another, it looks like this:

I've been ignoring it so far, but Douglas County is my county and that percentage looks ridiculous. Are there any tweaks I can make to the Arcade code to fix this?

Edited to add: I tried changing the rounding to 1 decimal place and it rounded our county up to 60%. Then I tried 0 and it rounded to 100%!! Oh my.

0 Kudos
1 Reply
New Contributor II

I just made a very similar arcade expression and noticed the same behavior that you're describing.  I decided to try rearranging the expression to multiply it by 100 before rounding, so that it looks more like the following. 


round(travelpercent*100, 2) + '%'


It seems to be giving me more consistent results now, though I don't have a lot of features to test it on.  


I read the documentation for the Round function, and it has a note that says to use the Text function to format numbers for display in labels and pop-ups.  After looking at the documentation, I altered my expression to include the text function instead, and it even multiplies by 100 for me.  

Text(travelpercent, '#.##%')

If you don't want decimals for your percentage, you will probably want to use the following format: 

Text(travelpercent, '#%')


0 Kudos