Arcade expression round decimal to zero decimal places

22718
12
Jump to solution
01-10-2019 01:33 PM
AndrewL
Occasional Contributor II

I have the following Arcade expression. However, it does not round to the nearest whole number. It always produces a number with two decimal places. Not sure if I am doing something wrong? Thanks.

var grid = $feature.GRIDCODE*10
var roundedValue = Round(grid, 0)
roundedValue

0 Kudos
12 Replies
XanderBakker
Esri Esteemed Contributor

Hi @DataOfficer ,

To avoid having to enter the list of fields and define how many decimals should be used you can use the Text function and format it the way you want. Have a look at the example below:

var x1 = PI * 100;
Console(x1);
var x2 = Round(x1, 3);
Console(x2);
var x3 = Text(x2, "#.00");
Console(x3);
var x4 = Text(x2, "#");
Console(x4);

 

This will write to the console:

314.1592653589793
314.159
314.16
314

 

  1. Contains the original value (PI * 100)
  2. The result of rounding it to 3 decimals (it is still a number)
  3. Converting to a text indicating to format it using always ("0") 2 decimals (even when 0)
  4. Converting to a text using no decimals and eliminating leading/trailing zeros ("#")
DataOfficer
Regular Contributor

Excellent thank you. I appreciate your continued advice on this forum.

YanisleyGuilarte
New Contributor

I have the same problem.

What I did was I create a new field (Double) field calculate all for my (Short )field. In ArcGISPro. 

In Web Map: I went to pop up and put "0 decimal Places". and resolve. 

YanisleyGuilarte_0-1686227357243.png

SO the field has to be DOUBLE

YanisleyGuilarte_1-1686227466995.png

 

0 Kudos