|
POST
|
Hi Sara Kidd , The DateAdd function can work with negative values. See example below: var dt = Now();
var fourdaysearlier = DateAdd(dt, -4, "days");
Console(dt);
Console(fourdaysearlier);
return fourdaysearlier; This will write the following text to the console: 2020-09-09T16:23:42-05:00
2020-09-05T16:23:42-05:00 As you can see you will have a date time of 4 days before. However you will need to use a date range to select records that were taken four days ago. Have a look at the example below (I assume the sql can be simplified, but I don't have the data to test this): var dt = Now();
var fourdaysearlier = DateAdd(dt, -4, "days");
var format = "MM/DD/Y";
var fourdaysearliertxt = Text(fourdaysearlier, format);
// let's assume your date field is called LASTUPDATE
// LASTUPDATE BETWEEN timestamp '04/30/1999 00:00:00' and date '04/30/1999 23:59:59'
var sql = "LASTUPDATE BETWEEN timestamp '" + fourdaysearliertxt + " 00:00:00' and date '" + fourdaysearliertxt + " 23:59:59'";
Console(dt);
Console(fourdaysearlier);
Console(fourdaysearliertxt);
Console(sql);
// filter featureset "timeseries" (should be defined earlier)
// var fs = Filter(timeseries, sql);
... View more
09-09-2020
02:44 PM
|
1
|
0
|
3550
|
|
DOC
|
Hi David Little , Sorry to tell you, but I haven't heard anything yet. I also haven't entered the beta for the next ArcGIS Online release, so I am not sure if it will be included in the next update later this month.
... View more
09-09-2020
01:30 PM
|
0
|
0
|
51015
|
|
POST
|
Hi Ekrem Canli , This should work. Not sure if there is something in the configuration of the data or the type of source that prevents the data from being updated. If you simplify the calculation just returning something like "test", does this work? (to rule out that you cannot use field calculations on the data). I assume that the output field is a Text field and the width is sufficient to hold the result?
... View more
09-09-2020
07:25 AM
|
0
|
2
|
8752
|
|
POST
|
Hi Timothy Woodfield , Glad to hear that it is working. The code looks OK. I see that you are returning the rounded age in months since the latest submission. As you noticed in the symbology profile you have no access to related data or other features. Therefore it is not possible to use the latest date to symbolize your features. You can calculate a field to obtain the information, but this will not automatically update when the data changes. In Enterprise and Desktop you could use an Attribute Calculation Rule to update the age of the latest submission, but this functionality is not yet available in ArcGIS Online. As an alternative you could schedule a task in Pro with a certain frequency to update the field, but changes made to the data will not be reflected in the symbology.
... View more
09-09-2020
07:22 AM
|
0
|
2
|
4259
|
|
POST
|
Hi Timothy Woodfield , In addition have a look at the expression below: // create date 31st of January, note the month is 0:
var dt = Date(2020, 0, 31);
Console("date: " + dt);
// extract the month value (will be 0)
var m = Month(dt);
Console("month: " + m);
// format the date
var format = "MM/DD/Y";
var txt = Text(dt, format);
Console("Formated date: " + txt);
return "OK"; This will write the following to the console: date: 2020-01-31T00:00:00-05:00
month: 0
Formated date: 01/31/2020 Be aware that when you use a Date function and need to specify the value for the month if will always be a value from 0 to 11. When you extract the month value from a date it will always be a value from 0 to 11. However, when you format a date it will return the month as a value from 1 to 12 as shown in the example.
... View more
09-08-2020
03:28 PM
|
0
|
0
|
4259
|
|
POST
|
Hi twoodfield_DawoodGIS , I would probably combine the last two examples and do this: // first read out the ID of the Feature1
var id = $feature.STATE_NAME;
// access the table Feature2
var tbl = FeatureSetByName($map, 'Registration Submissions');
// create a sql expression to query on ID
var sql = "STATE_NAME = '" + ID + "'";
// filter the table using the sql expression
var related_data = Filter(tbl, sql);
// validate if you have any related records
if (Count(related_data)>0) {
// get the max date and format the result
var maxepoch = Max(tbl, 'SubmissionDate');
var maxdate = Date(maxepoch);
var format = "MM/DD/Y";
return Text(maxdate, format);
} else {
// in case you don't have related records
// define what to return
return "";
}
... View more
09-08-2020
03:18 PM
|
0
|
5
|
4259
|
|
POST
|
Hi Timothy Woodfield , About the other question. Your month is 1 month off, since the Month function and Date function in Arcade (and JavaScript) expect you to specify the month as a value from 0 to 11 and not 1 to 12.
... View more
09-08-2020
03:01 PM
|
0
|
7
|
6586
|
|
POST
|
Hi twoodfield_DawoodGIS , I guess you don't have a date but an epoch in the field. Are you sure, the field is not a date but numeric? You could do something like this (provide the epoch to the Date function to get a date and then format it): var maxepoch = 1599609600000;
var maxdate = Date(maxepoch);
var format = "MM/DD/Y";
return Text(maxdate, format); This returned: 09/08/2020
... View more
09-08-2020
02:59 PM
|
0
|
0
|
6586
|
|
POST
|
Hi Mark Peacey , Coordinates of where a user clicked in the map cannot be accessed in Arcade. Nor is it possible to access the extent of the map and calculate the center of it. It would be nice to have. Arcade will need a geometry to get to the coordinate. For a point you will know where the user clicked, but for a polyline and polygon you will not know it (only that it was on the geometry or wihtin the tolerance of the geometry).
... View more
09-08-2020
02:53 PM
|
1
|
0
|
1272
|
|
POST
|
Hi Ekrem Canli , I would probably use the following expression, but it is a bit strange that he expression works as test in the GUI, but does not return any result when calculating. // point this to the field in the $feature
var UAV_arr1 = [Null, "DJI Inspire 3", "DJI Mavic Air 2", Null, "DJI Phantom 4 Pro V2.0"];
// remove null elements from array
var UVA_arr2 = [];
for (var i in UAV_arr1) {
if (!IsEmpty(UAV_arr1[i])){
UVA_arr2[Count(UVA_arr2)] = UAV_arr1[i];
}
}
// test to see if you have values in the array and return the result
if (Count(UVA_arr2)>0) {
return Concatenate(UVA_arr2, ", ");
} else {
// define what to return if you don't have any values
return "";
} Returns: DJI Inspire 3, DJI Mavic Air 2, DJI Phantom 4 Pro V2.0 Change the test to (only one element): var UAV_arr1 = [Null, Null, "DJI Mavic Air 2", Null, Null]; Returns: DJI Mavic Air 2 And without any values: var UAV_arr1 = [Null, Null, Null, Null, Null]; Returns an empty string...
... View more
09-08-2020
02:49 PM
|
0
|
4
|
8752
|
|
POST
|
Hi Timothy Woodfield , See the example below: // first read out the ID of the Feature1
var id = $feature.STATE_NAME;
// access the table Feature2
var tbl = FeatureSetByName($map, 'Registration Submissions');
// create a sql expression to query on ID
var sql = "STATE_NAME = '" + ID + "'";
// filter the table using the sql expression
var related_data = Filter(tbl, sql);
// validate if you have any related records
if (Count(related_data)>0) {
// get the max date and format the result
var maxdate = Max(tbl, 'SubmissionDate');
var format = "MM/DD/Y";
return Text(maxdate, format);
} else {
// in case you don't have related records
// define what to return
return "";
}
On lines 13 and 14 the date is formatted using a defined format. I would also recommend you to use the FeatureSetByRelationshipName function in case the related records are related through a RelationshipClass.
... View more
09-08-2020
02:32 PM
|
0
|
10
|
6588
|
|
POST
|
Hi Cassie Porter , I am sorry, buy I have not yet had the chance to play around a lot with Arcade in the new Field Maps App. I know that there will be better support for Arcade, but not sure what will be included and what not. Best way to find out would be to try it yourself by joining the beta program: ArcGIS Field Maps This would also be the place to request this functionality in case it is not included yet.
... View more
09-08-2020
01:00 PM
|
0
|
0
|
4498
|
|
POST
|
Hi Timothy Woodfield , In the pop-up you can certainly do this. We can have a look at this in more detail, but I would recommend to start a new question to avoid creating noise in this one.
... View more
09-08-2020
12:48 PM
|
0
|
0
|
6588
|
|
BLOG
|
Congratulations and thanks to all those mentioned here and who actively help to make this place such a great resource for the GIS community. Special congratulations to danretired who after being cloned was able to finish first. Great to see the usual suspects as elite level winners, but also a special thanks and congratulations to the “rookies” who despite of being “new” at the community have been willing to share their knowledge helping many others. Keep up the good work after we migrate to the new community platform!
... View more
09-08-2020
10:03 AM
|
7
|
0
|
3832
|
|
POST
|
Hi Joe Borgione , Actually there is a space related to Arcade that could be very helpful for you. It was created recently and is called Attribute Rules There are many resources available, but I agree that they are pretty scattered. You have however, a learn path for Arcade (Learn ArcGIS | Learn ArcGIS ) and the Arcade developer website (ArcGIS Arcade | ArcGIS for Developers ) offers a lot of information. There are many blogs about Arcade and a GitHub repository: GitHub - Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in the ArcGIS platform.
... View more
09-03-2020
10:23 AM
|
2
|
1
|
1471
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|