I am trying to create a string to provide a reduced look at tropical storm systems. I've gotten close but am struggling with looping and comparing the items since they are in different fields from different features. Since storms change in classification throughout the timeline I want to reduce to only show those changes. This would be my final block of text (or similar):
- Tropical Rainstorm: June 18, 2024 at 11:00 AM → Tropical Storm: June 19, 2024 at 11:00 PM → Tropical Depression: June 20, 2024 at 8:00 AM → Tropical Rainstorm: June 20, 2024 at 8:00 PM
Storm begins as a tropical rainstorm on the 18th, changes to a tropical storm on the 19th at 11pm, then a tropical depression on the 20th at 8am, and so on. It would be simple to grab Distinct values but I need to compare the Begin and End classifications then add the times.
_DATE_TIME is a date/time field, _LABEL is string
STORM_ID is the unique ID
| BEGIN_CLASSIFICATION | BEGIN_DATE_TIME | BEGIN_DATE_TIME_LABEL | END_CLASSIFICATION | END_DATE_TIME | END_DATE_TIME_LABEL | STORM_ID |
| Tropical Rainstorm | June 18, 2024 at 11:00 AM | Jun 18 2024 10:00AM CDT | Tropical Rainstorm | June 18, 2024 at 8:00 PM | Jun 18 2024 7:00PM CDT | 2,511 |
| Tropical Rainstorm | June 18, 2024 at 8:00 PM | Jun 18 2024 7:00PM CDT | Tropical Storm | June 19, 2024 at 8:00 AM | Jun 19 2024 7:00AM CDT | 2,511 |
| Tropical Storm | June 19, 2024 at 8:00 AM | Jun 19 2024 7:00AM CDT | Tropical Storm | June 19, 2024 at 8:00 PM | Jun 19 2024 7:00PM CDT | 2,511 |
| Tropical Storm | June 19, 2024 at 8:00 PM | Jun 19 2024 7:00PM CDT | Tropical Storm | June 19, 2024 at 11:00 PM | Jun 19 2024 10:00PM CDT | 2,511 |
| Tropical Storm | June 19, 2024 at 11:00 PM | Jun 19 2024 10:00PM CDT | Tropical Depression | June 20, 2024 at 8:00 AM | Jun 20 2024 7:00AM CDT | 2,511 |
| Tropical Depression | June 20, 2024 at 8:00 AM | Jun 20 2024 7:00AM CDT | Tropical Rainstorm | June 20, 2024 at 8:00 PM | Jun 20 2024 7:00PM CDT | 2,511 |
From this I expect needing to create a dictionary and or an array where I combine the Classification fields, Time Fields, and Time Labels where I can then perform a sort on the TIME
I've kept the TIME_LABEL since it is already a string and I wouldn't need to convert TIME later via Text().
| CLASSIFICATION | TIME | TIME_LABEL |
| Tropical Rainstorm | June 18, 2024 at 11:00 AM | Jun 18 2024 10:00AM CDT |
| Tropical Rainstorm | June 18, 2024 at 8:00 PM | Jun 18 2024 7:00PM CDT |
| Tropical Rainstorm | June 18, 2024 at 8:00 PM | Jun 18 2024 7:00PM CDT |
| Tropical Storm | June 19, 2024 at 11:00 PM | Jun 19 2024 10:00PM CDT |
| Tropical Storm | June 19, 2024 at 11:00 PM | Jun 19 2024 10:00PM CDT |
| Tropical Storm | June 19, 2024 at 8:00 AM | Jun 19 2024 7:00AM CDT |
| Tropical Storm | June 19, 2024 at 8:00 AM | Jun 19 2024 7:00AM CDT |
| Tropical Storm | June 19, 2024 at 8:00 PM | Jun 19 2024 7:00PM CDT |
| Tropical Storm | June 19, 2024 at 8:00 PM | Jun 19 2024 7:00PM CDT |
| Tropical Depression | June 20, 2024 at 8:00 AM | Jun 20 2024 7:00AM CDT |
| Tropical Depression | June 20, 2024 at 8:00 AM | Jun 20 2024 7:00AM CDT |
| Tropical Rainstorm | June 20, 2024 at 8:00 PM | Jun 20 2024 7:00PM CDT |
After that I would then run a for loop and compare the next value and if they match skip to result in a final as such:
| CLASSIFICATION | TIME | TIME_LABEL |
| Tropical Rainstorm | June 18, 2024 at 11:00 AM | Jun 18 2024 10:00AM CDT |
| Tropical Storm | June 19, 2024 at 11:00 PM | Jun 19 2024 10:00PM CDT |
| Tropical Depression | June 20, 2024 at 8:00 AM | Jun 20 2024 7:00AM CDT |
| Tropical Rainstorm | June 20, 2024 at 8:00 PM | Jun 20 2024 7:00PM CDT |
After that returning the items with the proper format of the string from above:
Tropical Rainstorm: June 18, 2024 at 11:00 AM → Tropical Storm: June 19, 2024 at 11:00 PM → Tropical Depression: June 20, 2024 at 8:00 AM → Tropical Rainstorm: June 20, 2024 at 8:00 PM
//grab the ID of the storm
var id = $feature.STORM_ID
//filter for all the features with the same ID
var fs = Filter(FeatureSetByName($map, 'Tropical_WOM',['BEGIN_CLASSIFICATION','BEGIN_DATE_TIME','END_CLASSIFICATION','END_DATE_TIME']), 'STORM_ID = <a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972">@ID</a>')
//count number of features for iterating
var items = Count(fs)
Console(items)
//set a counter to 0 for looping
var counter = 0
//add all the features to an array
var fs_arr = []
for(var f in fs) {
var c = Dictionary('BEGIN_CLASSIFICATION',`${f.BEGIN_CLASSIFICATION}`,'BEGIN_DATE_TIME',`${f.BEGIN_DATE_TIME}`,'END_CLASSIFICATION',`${f.END_CLASSIFICATION}`,'END_DATE_TIME',`${f.END_DATE_TIME}`)
Push(fs_arr, c)
}
console (fs_arr)
return fs_arr
Thanks in advance for the help