|
POST
|
Hi @Anonymous User , Arcade in the label profile only offers access to the attribute of the feature itself and not to other features or related data. The only way to have this information in the label, it to create another field and use a field calculation to extract the data you want to show in the label. If the data is dynamic, you will have to recalculate the field to update the information or implement an Attribute Rule to take care of this.
... View more
02-16-2021
05:40 AM
|
0
|
7
|
2291
|
|
POST
|
Hi @LukeAllen2 , To reply to the private message you send, have a look at the code snippet below that will take into account the leap year in a more logical way. // multiple years and days when there is a leapyear
var date1 = Date(2016, 1, 1); // February 1st 2016
var date2 = Date(2020, 2, 1); // March, 1st 2020
// calculate the years as usual
var years = Floor(DateDiff(date2, date1, 'years'));
// create a new date by adding the years to the start date
var date1a = DateAdd(date1, years, 'years');
// calculate the number of days between those date (will account for leap years)
var days = DateDiff(date2, date1a, 'days');
return years + " years and " + days + " days"; And to put this logic in your example, it will look like this: var timeNow = Now();
var survey = $feature["DATE_PAINT"];
var y = Floor(DateDiff(timeNow, survey, 'Years'));
var date1a = DateAdd(survey, y, 'years');
var d = DateDiff(timeNow, date1a, 'days');
if (IsEmpty($feature["DATE_PAINT"])){
return "-";
} else if (y >= 2) {
return "Last Painted: " + y + " years and " + Floor(d , 0) + " days ago.";
} else if (y == 1) {
return "Last Painted: 1 year and " + Floor(d , 0) + " days ago.";
} else if (y == 0 && d >= 2) {
return "Last Painted: " + Floor(d , 0) + " days ago.";
} else if (y == 0 && d >= 1) {
return "Last Painted: " + Floor(d , 0) + " day ago.";
} else if (y == 0 && d < 1) {
return "Last Painted: today.";
}
... View more
02-16-2021
05:32 AM
|
0
|
3
|
3785
|
|
POST
|
You're welcome @LukeAllen2 . Sorry for the error in the function. It is a bit weird that it was a valid expression in the expression builder. (I also worked with the error in Pro, when it shouldn't have worked...)
... View more
02-15-2021
01:29 PM
|
0
|
1
|
3797
|
|
POST
|
Hi @LukeAllen2 , My bad. Apparently, there is a line missing in the function. Can you try this? function daysThisYear() {
// https://stackoverflow.com/questions/16353211/check-if-year-is-leap-year-in-javascript
var y = Year(Now());
// check leap year
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
return 366;
} else {
return 365;
}
}
var timeNow = Now();
var survey = $feature["DATE_PAINT"];
// var survey = Date(2015, 1, 1);
var years = DateDiff(timeNow, survey, 'Years');
var y = Floor(years, 0);
var d = Round((years - y) * daysThisYear(), 0);
if (IsEmpty($feature["DATE_PAINT"])){
return "-";
} else if (y >= 2) {
return "Last Painted: " + y + " years and " + Floor(d , 0) + " days ago.";
} else if (y == 1) {
return "Last Painted: 1 year and " + Floor(d , 0) + " days ago.";
} else if (y == 0 && d >= 2) {
return "Last Painted: " + Floor(d , 0) + " days ago.";
} else if (y == 0 && d >= 1) {
return "Last Painted: " + Floor(d , 0) + " day ago.";
} else if (y == 0 && d < 1) {
return "Last Painted: today.";
}
... View more
02-15-2021
01:19 PM
|
1
|
3
|
10781
|
|
POST
|
Hi @LukeAllen2 , Can you validate if the feature has a painted date and can you see in the developer options of the browser if there is any error message when you click on the feature?
... View more
02-15-2021
12:03 PM
|
0
|
5
|
6990
|
|
POST
|
Hi @Anonymous User , In your explanation, you mention that you want to show this text as a label. In ArcGIS Online with Arcade in the label profile, you can only access the data of the current feature and not of related data. The error message indicating that $datastore is not found is due to that. You can find more information about profiles and the functionality available in each profile here: https://developers.arcgis.com/arcade/guide/profiles/ I would also use FeatureSetByRelationshipName to access related information. With the amount of information to display it seems to me that using a pop-up (where this functionality does work) is the logical option. If you configure this with Arcade it will only be available in ArcGIS Pro and ArcGIS Online (and Enterprise) but not in ArcMap.
... View more
02-15-2021
05:26 AM
|
0
|
9
|
2310
|
|
POST
|
Hi @map16jamie , A quick note on performance. You should not carry out the same calculation multiple times. It would be better to do something like this: var months = DateDiff(Now(), Date($feature.CreationDate), 'months');
if (months <= 😎 {
return "Surveyed within the last 8 months";
} else if (months > 8 && months <= 10) {
return "Surveyed between 8 to 10 months ago";
} else if (months > 10 && months <= 12) {
return "Surveyed between 10 to 12 months ago";
} else {
return "Surveyed more than 12 months ago";
} I also have used AGO assistant in the past, not to change the maxPaginationRecords, but to define the symbols in case some were missing. Worked like a charm, but remember what @Roquinn advised (make a copy of the web map since you can end up making it invalid).
... View more
02-13-2021
02:23 PM
|
0
|
0
|
1139
|
|
POST
|
Hi @kirken , To confirm Dan's suspicion, Attribute Rules will only work with Arcade expressions. You cannot create an attribute rule using Python as the expression. The link shared by @DanPatterson before uses Python to configure the Attribute Rule, but inside it is still using the Arcade expression defined as a string inside the Python script. In short, if you want to use Attribute Rules you will always need Arcade...
... View more
02-13-2021
02:10 PM
|
2
|
1
|
4919
|
|
POST
|
Hi @LukeAllen2 , I think this thread is related to what you send me by private message. You can use a function that will determine the number of days in a year (taking into account the leap years): function daysThisYear() {
// https://stackoverflow.com/questions/16353211/check-if-year-is-leap-year-in-javascript
// check leap year
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
return 366;
} else {
return 365;
}
} And below the complete expression: function daysThisYear() {
// https://stackoverflow.com/questions/16353211/check-if-year-is-leap-year-in-javascript
// check leap year
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
return 366;
} else {
return 365;
}
}
var timeNow = Now();
var survey = $feature["DATE_PAINTED"];
// var survey = Date(2015, 1, 1);
var years = DateDiff(timeNow, survey, 'Years');
var y = Floor(years, 0);
var d = Round((years - y) * daysThisYear(), 0);
if (IsEmpty($feature.DATE_PAINTED)){
return "-";
} else if (y >= 2) {
return "Last Painted: " + y + " years and " + Floor(d , 0) + " days ago.";
} else if (y == 1) {
return "Last Painted: 1 year and " + Floor(d , 0) + " days ago.";
} else if (y == 0 && d >= 2) {
return "Last Painted: " + Floor(d , 0) + " days ago.";
} else if (y == 0 && d >= 1) {
return "Last Painted: " + Floor(d , 0) + " day ago.";
} else if (y == 0 && d < 1) {
return "Last Painted: today.";
}
... View more
02-13-2021
02:01 PM
|
1
|
7
|
7024
|
|
POST
|
Hi @RichardBurdett1 , As far as I know, ArcGIS Online does not allow you to define a symbol size that way. You can mimic this behaviour, by using the $view.scale, but this will require you to define symbols for each range of view scales. Not a very user-friendly option and you will probably need to "hack" the json of the webmap, since the symbol editor will only offer you to edit the symbol(s) of the features at the current view scale.
... View more
02-13-2021
01:56 PM
|
1
|
0
|
1185
|
|
POST
|
Hi @CalebMeliesPearce , I'm just wondering if you should do this with an immediate calculation attribute rule and not a validation attribute rule. But when you use a constraint of validation attribute rule, you probably need to have validation capabilities enabled on the services and meet a couple of other requirements... https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/evaluate-attribute-rules.htm https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/share-datasets-with-attribute-rules.htm
... View more
02-13-2021
01:52 PM
|
0
|
4
|
6346
|
|
POST
|
Hi @Anonymous User , I wish I had an answer for you, but I don't have a lot of experience in using Arcade in the Dashboard. I tried some stuff in the beginning, but it was limited to accessing data in the datapoint only and therefore I haven't used it very much. I have heard that you will be able to use Arcade as data source and that should increment the possibilities to a whole new level (can't wait for that). What it seems like, is that you just have access to the first datapoint, although filtering for Pump station 1 should get you 3 values. The other thing is how Arcade will treat Null values. have a look at the example below. If a list contains a null value, the value will be treated as 0, in my example, this will return an invalid min statistic and also an invalid average statistic. [1,2,3,4,5,null]
min:0
max:5
sum:15
avg:2.5
... View more
02-13-2021
01:42 PM
|
1
|
1
|
3524
|
|
POST
|
Hi @TL2 , Since you don't have a variable a and b, the code will fail. You can use the indexes (0 and 1) to extract the "a" and "b" values: "q_2control": myArray[os][0],
"choice": myArray[os][1]
... View more
02-12-2021
05:32 AM
|
1
|
0
|
2467
|
|
POST
|
Hi @DougBrowning , Thanks for the explanation. It makes sense. I would have to do some tests to see what is happening and if I can reproduce it. In the meantime, let me CC @JeffShaner who knows everything there is to know about the product.
... View more
02-12-2021
05:14 AM
|
1
|
0
|
2605
|
|
POST
|
Hi @jstark_mercernj @JoeBorgione is correct, Attribute Rules are the way to go, but unfortunately only available for data stored in an Enterprise GDB or a File GDB. It will come to AGOL but I don't have an ETA at this point.
... View more
02-11-2021
06:37 AM
|
1
|
5
|
7479
|
| 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 |
11-26-2025
02:43 PM
|