Select to view content in your preferred language

Experience Builder Labels (Rounding to 4 decimal places)

350
3
Jump to solution
05-21-2024 03:13 AM
Labels (1)
StephenDuncan
New Contributor II

Morning,

I am fairly new to Experience Builder and writing label expressions in Experience builder which I believe uses JavaScript/Arcade?

I have a field called "WAYMARK_VALUE" which has been rounded to 4 decimal places in the 'Fields' list and it also shows correctly in the pop up box shown below. When applying the labels it seem to have a mixture of decimal places, from zero places and to the correct 4 places, so i am a bit puzzled why this is not working?

I have copied a piece of script I found online which i thought would work, but unfortunately it doesn't seem to consistently work, so any help would be much appreciated.

Once i have the rounding issue sorted, i would then like to add multiple attributes to my label expression, ideally the "ELR" attribute and the "WAYMARK_VALUE" rounded to 4 decimal places. (ie;  BLT1 - 47.0880

StephenDuncan_0-1716284928373.png

StephenDuncan_1-1716284970211.png

 

Many thanks,

Steve

0 Kudos
1 Solution

Accepted Solutions
IssyAmis
Esri Contributor

Hi @StephenDuncan 

Thanks for your question.

Looking into the documentation for the "Round" function, it seems to be expected that any trailing zeros will be truncated - which I assume is the behaviour you are experiencing, rather than the rounding not working at all? https://developers.arcgis.com/arcade/function-reference/math_functions/#round

From what I can tell, there does not seem to be a way at the moment to stop this behaviour. If you take a look through this documentation: How To: Retain Trailing Zeros after the Decimal Point in a Label Using Arcade in ArcGIS Pr (esri.com... we do have a workflow in Arcade to resolve this in ArcGIS Pro that is worth trying for your labels - although I have not yet been able to get this to work in ArcGIS Online.

Let me know if you have any questions about any of the above!

Thanks,

Issy

View solution in original post

0 Kudos
3 Replies
IssyAmis
Esri Contributor

Hi @StephenDuncan 

Thanks for your question.

Looking into the documentation for the "Round" function, it seems to be expected that any trailing zeros will be truncated - which I assume is the behaviour you are experiencing, rather than the rounding not working at all? https://developers.arcgis.com/arcade/function-reference/math_functions/#round

From what I can tell, there does not seem to be a way at the moment to stop this behaviour. If you take a look through this documentation: How To: Retain Trailing Zeros after the Decimal Point in a Label Using Arcade in ArcGIS Pr (esri.com... we do have a workflow in Arcade to resolve this in ArcGIS Pro that is worth trying for your labels - although I have not yet been able to get this to work in ArcGIS Online.

Let me know if you have any questions about any of the above!

Thanks,

Issy

0 Kudos
StephenDuncan
New Contributor II

Afternoon Issy,

Thank you for getting back to me on this and supplying the links to the information. I have played around with the Text function and it seems to have worked in ArcGIS Online Experience builder on the labels 🙂

StephenDuncan_0-1716295027142.png

This was the script that seems to work for me:

Text($feature.WAYMARK_VALUE,'###.0000')
StephenDuncan_1-1716295196713.png

 

 
Hopefully you are also able to get it to work for you!
 
Appreciate your help,
 
Many thanks,
Steve 
IssyAmis
Esri Contributor

Hi @StephenDuncan 

That's great, I'm glad that's worked for you!

Issy

0 Kudos