Select to view content in your preferred language

GroupBy Arcade in data expression for Dashboard

382
0
02-12-2024 09:04 AM
Labels (1)
mfafard
Emerging Contributor

Hi

I have to GroupBy "nojob" the follwing code. I split at comma a field to have it in different lines in dashbord. I really don't know how I can add a groupby "nojob" in this case...

 

var portal = Portal('https://xxx.xxxxx.ca/portal');
var fs = FeatureSetByPortalItem(
portal,
// Item ID of the jobsignalisation layer
'250b512105df48169e8d01a0xxxxxxxx',
// Layer ID
2,
// Fields of interest
[
'nojob', 'resumeinterventiondemandee', 'resumeinterventiondemandeep'
],
// Not Need geometry
false);

// Initialize the result variable
var final_result = '';

// Iterate through each entity in the FeatureSet
for (var f in fs) {
// Get the field values for this entity
var top_text = f.nojob;
var text1 = f.resumeinterventiondemandee;
var text2 = f.resumeinterventiondemandeep;

// Use split to divide the text by commas
var elements1 = Split(text1, ',');
var elements2 = Split(text2, ',');

// Initialize result variables for both fields
var result1 = '';
var result2 = '';

// Iterate over the elements and add them to the result variable
for (var i in elements1) {
result1 += elements1[i] + TextFormatting.NewLine;
}

for (var j in elements2) {
result2 += elements2[j] + TextFormatting.NewLine;
}

// Concatenate the results with the top text and an empty line between them
final_result += top_text + TextFormatting.NewLine + TextFormatting.NewLine + result1 + result2 + TextFormatting.NewLine + TextFormatting.NewLine;
}

return final_result;

Tags (2)
0 Kudos
0 Replies