ARCADE Groups BY Function

201
0
02-02-2023 08:43 AM
Labels (2)
MOGOMAINTERNE
New Contributor

Hello,

In AGOL, I want to return a result with a loop (contextual window) depending on the value present in a field. I'm a beginner with ARCADE and I can't do what I want


My ARCADE expression is:

// Acess 'Groundwater Levels Monthly Mean' table as a FeatureSet
var portal = Portal("https://www.arcgis.com")
var waterLevels = FeatureSetByPortalItem(portal,
"2700a42fce724cd588477fd60f1d84c1", 1, ['Commande', 'Etat_Pose',
'Ref_Gravee', 'Num_poteau', 'Ligne','Texte', 'Altitude', 'Longueur','Tps_pedestre', 'Altitude', 'Sens'])

// Filter related features by using a common attribute
var NUM_ENTITE = $feature["NUM_ENTITE"]
var filterStatement = 'Num_poteau = @NUM_ENTITE'

// Related features as a variable
var relatedData = Filter(waterLevels, filterStatement)

// Sort related features by oldest to newest
var relatedDataSorted = OrderBy(relatedData, 'Ref_Gravee')

// Build the pop-up string by iterating through all related features
var popupString = ''
for (var f in relatedDataSorted){

popupString += f.Ref_Gravee + TextFormatting.NewLine +

f.Commande + f.Texte + f.Longueur + TextFormatting.NewLine

}

DefaultValue(popupString, 'No measurements to show')

 

My result : 

38206_048_A
AucuneLaval - Château
38206_048_B
A commander 2022 - 07LAVAL - Mairie0.4 km
38206_048_B
A commander 2022 - 07Laval - Église0.3 km
38206_048_C1
Commande N°03 2021LES ADRETS5.4 km
38206_048_C1
Commande N°03 2021COL DU LAUTARET4.3 km
38206_048_C2
Commande N°03 2021LES CRÊTS2.4 km
38206_048_C2
Commande N°03 2021TOUR DE MONTFALLET0.6 km
38206_048_D
AucuneLE CHAMP PRES FROGES3.3 km
38206_048_D
AucuneFROGES3.3 km
38206_048_D
AucuneCôtes Rousses0.8 km

 

What I want: to group my result according to the 'Ref_Gravee' field. I tried with GROUP BY and FOR IN but I can't.

38206_048_A
AucuneLaval - Château

38206_048_B
A commander 2022 - 07LAVAL - Mairie0.4 km
A commander 2022 - 07Laval - Église0.3 km

38206_048_C1
Commande N°03 2021LES ADRETS5.4 km
Commande N°03 2021COL DU LAUTARET4.3 km


38206_048_C2
Commande N°03 2021LES CRÊTS2.4 km
Commande N°03 2021TOUR DE MONTFALLET0.6 km

38206_048_D
AucuneLE CHAMP PRES FROGES3.3 km
AucuneFROGES3.3 km
AucuneCôtes Rousses0.8 km

 

Thanks a lot for your help
Do not hesitate if you need clarification

 

Aurélien

0 Kudos
0 Replies