Select to view content in your preferred language

no thousands separators in Table Attribute when using Arcade expression

310
1
Jump to solution
06-10-2024 06:42 AM
Labels (1)
BertKraan1
Frequent Contributor

Pro 3.3.0

When inserting a Table Attribute in my layout I can choose to display a Thousands Separator when displaying a field (left) but when I compose an expression this choice disappears (right)

BertKraan1_0-1718025198822.png BertKraan1_1-1718025220417.png

Is there a way to have a separator AND use an expression? 

 

I have for example a surface of 2243 in a table which I would like to display as 2.234 ha. At the moment it displays either 2.234 or 2234 ha

 

I tried adding the separator in Arcade using

Text($feature.surface, '###,###') and that does work but displays a comma 2,234 where we would use a colon in the Netherlands. My locale is set correct (in Windows)

When using Text($feature.surface, '###.###') (with a colon) the colon is ignored.

 

Any advice would be appreciated, thanks for your time.

 

Bert

0 Kudos
1 Solution

Accepted Solutions
AubriKinghorn
Esri Regular Contributor

Unfortunately, Arcade doesn't support this directly (yet!) but you can do it manually with a find and replace. Here's some sample code from @JohannesLinder is in this post https://community.esri.com/t5/arcgis-pro-questions/arcade-label-dynamic-text-with-thousands-separato...

var value = 1234567890 / 1000
var x = Text(value, "#,###.0")
var pat_rep = [[".", ";"], [",", "."], [";", ","]]
for (var i in pat_rep) {
    x = Replace(x, pat_rep[i][0], pat_rep[i][1])
}
return x + " kt"

// 1.234.567,9 kt

 

 

Also,  the delimiter and decimal place options are disabled in the window when using an expression because they only apply to numeric data, and there is no guarantee when using an expression that a number will be the output. So you have to control those within the expression instead.  

Cheers,
Aubri

View solution in original post

0 Kudos
1 Reply
AubriKinghorn
Esri Regular Contributor

Unfortunately, Arcade doesn't support this directly (yet!) but you can do it manually with a find and replace. Here's some sample code from @JohannesLinder is in this post https://community.esri.com/t5/arcgis-pro-questions/arcade-label-dynamic-text-with-thousands-separato...

var value = 1234567890 / 1000
var x = Text(value, "#,###.0")
var pat_rep = [[".", ";"], [",", "."], [";", ","]]
for (var i in pat_rep) {
    x = Replace(x, pat_rep[i][0], pat_rep[i][1])
}
return x + " kt"

// 1.234.567,9 kt

 

 

Also,  the delimiter and decimal place options are disabled in the window when using an expression because they only apply to numeric data, and there is no guarantee when using an expression that a number will be the output. So you have to control those within the expression instead.  

Cheers,
Aubri
0 Kudos