Select to view content in your preferred language

Rounding integer values

630
4
06-28-2023 05:45 AM
AbiDhakal
Occasional Contributor III

Hello GIS friends,

I'm doing a simple calculation using arcade expression for an Attribute rule in ArcGIS Pro. I got the calculations to work, however I'm not knowing how to round up the integer value to the highest number. Both the field types are integer and not double. Also, the field where the output gets calculated is type integer.
Example: Average of (50+51) = 51 when you round up to the highest number, but I'm getting 50 with the expression I'm using.
Here is my expression: Mean($feature.Field1,$feature.Field2)

Thank you,
Abi

0 Kudos
4 Replies
AyanPalit
Esri Regular Contributor

@AbiDhakal try: Round (Mean($feature.Field1,$feature.Field2))

Ayan Palit | Principal Consultant Esri
0 Kudos
AbiDhakal
Occasional Contributor III

@AyanPalit, that does not seem to work Ayan. With your expression:
Round (Mean($feature.Field1,$feature.Field2))
The average of two integers (214+215) = 214 instead of 215

Thank you,
Abi

0 Kudos
ChrisUnderwood
Esri Contributor

Hello @AbiDhakal 

Ceil(Mean($feature.Field1,$feature.Field2),0)

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

"Returns the input value rounded upwards to the given number of decimal places."

Gives the result 215 when Field1 is 214 & Field2 is 215.

 

AbiDhakal
Occasional Contributor III

Hello@ChrisUnderwood 

Good morning and happy Friday to you! My apology for the late response, Chris. I was only able to get to it this morning. The expression worked great. Thank you!

Also, I used 'Ceil' on a subsequent expression, but that part didn't work for me.
Here is what I did and on this one it didn't work.
Ceil(Sum($feature.Field1,$feature.Field2,$feature.Field3*.25),0)

Thank you,
Abi


0 Kudos