Select to view content in your preferred language

Data Expression fail after November update

417
1
Jump to solution
11-19-2024 08:31 AM
AmeWunderle
Regular Contributor

Hi everyone,

After the November update a data expression that worked previously is not working anymore. 

I was able to pinpoint where it goes wrong, and its now the GroupBy expression. I can't use it to get a max date anymore. I get an empty table. If I change the statistic to "COUNT", it works. I can use the "MAX" statistic on any numeric field but no longer on the date fields.

My dictionary is set up as 

var MainDict = {
  fields: [
      {name:'globalId', type:'esriFieldTypeString'}
    ,{name:'objectid', type:'esriFieldTypeInteger'}
    ,{name:'Cor_Date', type: 'esriFieldTypeDate'}    
    ,{name:'Contractor', type: 'esriFieldTypeString'}
    ,{name:'Staff', type: 'esriFieldTypeString'}
    ,{name:'Cor_Expiry', type: 'esriFieldTypeDate'}
    ,{name:'activity', type: 'esriFieldTypeString'}    
   
  ],
  geometryType:'',
  features:featArray,
};

var data = FeatureSet(Text(MainDict))
 
"return data" gives me the feature set, but I need to filter this to show only one record for each Contractor, activity and only the record with the latest expiry date.  My group by statement was the following.
 
var test = GroupBy(data,['Contractor','activity'],[{name:'Cor_Expiry',expression:'Cor_Expiry',statistic:'MAX'},{name:'objectid',expression:'objectid',statistic:'MAX'}])
return test
 
I used to get a table that showed each contractor and activity with the most recent expiry date
 
Now I get the following:
AmeWunderle_0-1732033771916.png

Ideas on why the max statistic isn't working for dates anymore?  

0 Kudos
1 Solution

Accepted Solutions
AmeWunderle
Regular Contributor

So to fix this, I had to change my expiry date to DateOnly and convert to Text. In addition, changing the esri Field Type to string.

Once that was done, I could get the max date.

In my dashboard list, I then converted the expiry date back to a date so that I could change the colour of the results based on whether it was expired or not. 

View solution in original post

0 Kudos
1 Reply
AmeWunderle
Regular Contributor

So to fix this, I had to change my expiry date to DateOnly and convert to Text. In addition, changing the esri Field Type to string.

Once that was done, I could get the max date.

In my dashboard list, I then converted the expiry date back to a date so that I could change the colour of the results based on whether it was expired or not. 

0 Kudos