Format number, domain and subtypes in arcade pop-up (1:M)

544
4
Jump to solution
05-25-2021 11:34 AM
FabioLuiz
New Contributor III
Hello, my name is Fábio Luiz, I am a Brazilian resident in São Paulo. ESRI technical support helped me build an arcade expression for pop-up with 1:M data.
____________________________________________________
var id = $feature.Inscricao;
var tbl = FeatureSetByName($map,"Cadastro");
var sql = "Inscricao = '" + id + "'";
var related_data = Filter(tblsql);
var cnt = Count(related_data);
var result = cnt

if (cnt > 0) {
    for (var row in related_data) {
        var line = 
        TextFormatting.Newline +
        TextFormatting.Newline + "Setor: " + row.Setor + " / Quadra: " + row.Quadra + " / Lote: " + row.Lote + " / Unidade: " + row.Unidade +
        TextFormatting.Newline + "Lançamento: " + row.Lancamento + 
        TextFormatting.Newline + "Endereço: " + row.Endereco +
        TextFormatting.Newline + "Complemento: " + row.Complemento +
        TextFormatting.Newline + "Bairro: " + row.Bairro +
        TextFormatting.Newline + "Zona: " + row.Zona +
        TextFormatting.Newline + "Face de Quadra: " + row.Face +
        TextFormatting.Newline + "Testada: " + row.Testada +
        TextFormatting.Newline + "Terreno: " + row.ATer +
        TextFormatting.Newline + "Construção: " + row.AConstr +
        TextFormatting.Newline + "Tipo: " + row.TipoCod +
        TextFormatting.Newline + "Padrão: " + row.PadraoCod +
        TextFormatting.Newline + "Valores do m2 (PVG 2013)" +
        TextFormatting.Newline + "Terreno: R$ " + row.PVG2013M2Terreno +
        TextFormatting.Newline + "Construção: R$ " + row.PVG2013M2Construcao +
        TextFormatting.Newline;
        result += line;
}
else {
    result = "Lote sem dados relacionados:";
}

return result;

____________________________________________________

code made it possible to display the data:
 
popup.png
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Note that here there are some problems to be solved, are these:
 
fields with domains are not loaded properly to: 
  • Bairro
  • Zona
  • Tipo
  • Padrão
 
 values without decimal symbology and complement from zero to:
  • Testada
  • Terreno
  • Construção
  • Valor Terreno
  • Valor Construção
Question: does this approach allow you to correctly display domains, subtypes, and numeric format?
 
 
How to help understanding, the data in my table is as in the figure:
supportAGOL.png
 

 

0 Kudos
2 Solutions

Accepted Solutions
Peter_Klingman
Esri Regular Contributor

Hi @FabioLuiz - you'll want to use Decode() to translate the coded value domains to the text you want to display. For formatting numbers, you'll want to use Text()

Hope this helps,

-Peter

View solution in original post

Peter_Klingman
Esri Regular Contributor

Hi @FabioLuiz, your situation is a little bit interesting because the inclusion of the R$ in your field means that the numbers are stored as text. You could just manipulate the text field, but you could also convert to number and then back to text. I think the latter approach is better as the numbers are coming in without dividers to split by and are likely different lengths. See the example below: 

var fld = 'R$ 12345.67'
var num = Number(Right(fld, count(fld) -3))
return "R$ " + Text(num, "###,###.##")
// returns R$ 12.345,67

Hope this helps,

-Peter

View solution in original post

0 Kudos
4 Replies
Peter_Klingman
Esri Regular Contributor

Hi @FabioLuiz - you'll want to use Decode() to translate the coded value domains to the text you want to display. For formatting numbers, you'll want to use Text()

Hope this helps,

-Peter

View solution in original post

FabioLuiz
New Contributor III

Hi @Peter_Klingman , 

the decode function works, thank you very much.

unfortunately I didn't understand how to use the TEXT () function.

The example I saw was:
- Text (12345678.123, '#. ###, 00') features '12 .345,678.12 '
- Text (1234.55, 'R $ #, ###. 00') presents 'R $ 1,234.55'

I don't know where I put it and if I need to declare a var.

0 Kudos
Peter_Klingman
Esri Regular Contributor

Hi @FabioLuiz, your situation is a little bit interesting because the inclusion of the R$ in your field means that the numbers are stored as text. You could just manipulate the text field, but you could also convert to number and then back to text. I think the latter approach is better as the numbers are coming in without dividers to split by and are likely different lengths. See the example below: 

var fld = 'R$ 12345.67'
var num = Number(Right(fld, count(fld) -3))
return "R$ " + Text(num, "###,###.##")
// returns R$ 12.345,67

Hope this helps,

-Peter

View solution in original post

0 Kudos
FabioLuiz
New Contributor III

I agree with you, the second choice is better. Thank you very much for your help!