Hi
The following code work. But hard to believe that I can't groupby the 4 left characters of field "nojob"...
I tried lot of scenario, without success
var portail = Portal('https://xxxxx.ca/portal');
var fs = FeatureSetByPortalItem(
portail,
//itemid layer jobsignalisation
'250b512105df48169e8d01xxxxxxxxxx',
//layer id
0,
[
'nojob'
],
false);
var group_exp = [
{ name: 'jobsparannee', expression: 'nojob', statistic: 'COUNT'}]
return GroupBy(fs,['nojob'], group_exp)
return fs
Solved! Go to Solution.
Yes, I used test data here...
Your expression would look like this:
var portail = Portal('https://xxxxx.ca/portal');
var fs = FeatureSetByPortalItem(
portail,
//itemid layer jobsignalisation
'250b512105df48169e8d01xxxxxxxxxx',
//layer id
0,
[
'nojob'
],
false);
return GroupBy(fs,
[{name: "test", expression: "SUBSTRING(nojob, 1, 4)"}],
[{name: "test_count", statistic: "COUNT", expression: "1"}]
)
var fs = Featureset({
fields: [{name:"nojob", type:"esriFieldTypeString"}],
features:[
{attributes: {nojob: "abcdefg"}},
{attributes: {nojob: "abcdabc"}},
{attributes: {nojob: "abcd"}},
{attributes: {nojob: "uvwx"}},
{attributes: {nojob: "uvwxabc"}},
]
})
return GroupBy(fs,
[{name: "test", expression: "SUBSTRING(nojob, 1, 4)"}],
[{name: "test_count", statistic: "COUNT", expression: "1"}]
)
Thank you Johannes, but my field "nojob" come from an attributes rule (year(now()) + - + sequentiel). So, I want to count how many job in 2024, etc.
Yes, I used test data here...
Your expression would look like this:
var portail = Portal('https://xxxxx.ca/portal');
var fs = FeatureSetByPortalItem(
portail,
//itemid layer jobsignalisation
'250b512105df48169e8d01xxxxxxxxxx',
//layer id
0,
[
'nojob'
],
false);
return GroupBy(fs,
[{name: "test", expression: "SUBSTRING(nojob, 1, 4)"}],
[{name: "test_count", statistic: "COUNT", expression: "1"}]
)
Yep, thank you! I didn't think about these two steps (substring then count...)
Glad to help 🙂 If your question is answered, please mark the solution so that this thread shows as answered.