Select to view content in your preferred language

Arcade question - how to convert to whole number?

1254
5
Jump to solution
08-12-2023 11:14 PM
TTtttTeee
Occasional Contributor

Hello, I am struggling to convert values with decimal numbers to whole number in Arcade expression for pop-ups in AGOL. Code that I prepared returns values like "12.00", which includes decimal numbers, and I would like to convert them to whole numbers like "12" in pop-ups. My script below does not work unfortunately; thus, if anyone could give me an advice, that would be much appreciated. 

// Get number of points that intersect with polygon

var lu = FeatureSetByName($map, "pointA", ["incident_name"])

var xs = Intersects(lu, $feature)

var count_num = Count(xs)

var whole_number_count = Floor(count_num)

return whole_number_count
Tags (2)
1 Solution

Accepted Solutions
ChristopherCounsell
MVP Regular Contributor
Are you working in map viewer classic?

Go to popup > attribute values. There is an option for decimal places here
on each field.

I believe the expression returned value may be in here and able to be
configured to zero decimal places

Not sure in new map viewer

View solution in original post

5 Replies
ChristopherCounsell
MVP Regular Contributor

https://developers.arcgis.com/arcade/function-reference/math_functions/#round

Text(mynumber,'#')
Round(mynumber)
Floor(mynumber)
 
All work for me in the Arcade playground
0 Kudos
TTtttTeee
Occasional Contributor

Thanks for your reply.

Text function worked but Round and Floor function did not work. Both Round and Floor function work in Arcade playground but it did not show whole number in Pop-ups in a web map for some reasons. Do you know why only text function works?

0 Kudos
ChristopherCounsell
MVP Regular Contributor
Are you working in map viewer classic?

Go to popup > attribute values. There is an option for decimal places here
on each field.

I believe the expression returned value may be in here and able to be
configured to zero decimal places

Not sure in new map viewer
TTtttTeee
Occasional Contributor

Thanks magisian,

Yes, this is it, I managed to configure the type of field for the pop-ups and zero decimal places that agree with Arcade expression.