POST
|
Chrome (140.0.7339.186) and Firefox (143.0.1) work, but Edge (140.0.3485.81) doesn't for me.
... View more
15 hours ago
|
0
|
0
|
3
|
POST
|
Here's one way to calculate the difference (this shows the number of days since the beginning of the year). Note that the month number in the Date function is 0-based (0 is January) function StringToDate(input) {
var arrDate = Split(input, "/");
return Date(arrDate[2], arrDate[1] - 1, arrDate[0]);
}
var date1 = "01/01/2025";
var date2 = Text(Now(), "DD/MM/Y"); //gives today's date as dd/mm/yyyy
Floor(DateDiff(StringToDate(date2), StringToDate(date1), "days")); If your goal is to put this number into an indicator, then you have to return a FeatureSet containing that number function StringToDate(input) {
var arrDate = Split(input, "/");
return Date(arrDate[2], arrDate[1] - 1, arrDate[0]);
}
var date1 = "01/01/2025";
var date2 = Text(Now(), "DD/MM/Y"); //gives today's date as dd/mm/yyyy
var days = Floor(DateDiff(StringToDate(date2), StringToDate(date1), "days"));
return FeatureSet(
{
fields: [{ name: "Days", type: "esriFieldTypeInteger" }],
features: [{ attributes: { Days: days } }]
}
);
... View more
yesterday
|
0
|
0
|
48
|
POST
|
First, check all the field names. I may have overlooked changing one back to your schema. Click the Run button in the Arcade editor to see if it's returning a FeatureSet. Add some Console messages to see what the code is doing a various intervals. This should help you figure out what's going wrong.
... View more
yesterday
|
0
|
1
|
23
|
POST
|
That code should be var features = FeatureSetByName($map, 'Kartirane geoloske jedinice', ['PreferisanaStarost'], true);
Distinct(features, 'PreferisanaStarost');
... View more
Tuesday
|
0
|
0
|
24
|
POST
|
When posting code, please use the "Insert/edit code sample" button. It's easier to read and copy the code. A data expression must return a FeatureSet. Your code just returns an array of text strings. // Portal URL
var portalURL = "https://gis.(COMPANY_NAME).com/portal";
// Feature Layer ItemID
var layerItemID = "itemID";
// Layer index (usually 0)
var layerIndex = 0;
// Fields to include
var fields = ["T4PERMIT", "COMMODITY1", "OD", "Length_Miles"];
// Get FeatureSet from portal item
var fs = FeatureSetByPortalItem(
Portal(portalURL),
layerItemID,
layerIndex,
fields,
false
);
var grouped = GroupBy(
fs,
["T4PERMIT", "COMMODITY1", "OD"],
[{ name: "TotalMileage", expression: "Length_Miles", statistic: "SUM" }]
);
var finalResults = [];
for (var permit in Distinct(grouped, "T4PERMIT")) {
var permitVal = permit["T4PERMIT"];
var permitGroup = Filter(grouped, "T4PERMIT = @permitVal");
var textBlock = "<b>T4 Permit:</b> " + permitVal + "<br>";
for (var comm in Distinct(permitGroup, "COMMODITY1")) {
var commVal = comm["COMMODITY1"];
textBlock += " • <b>Commodity:</b> " + commVal + "<br>";
var commGroup = Filter(permitGroup, "COMMODITY1 = @commVal");
for (var row in commGroup) {
textBlock += "  ◦ <b>OD:</b> " +
row["OD"] +
" – <b>Mileage:</b> " +
Round(row["TotalMileage"], 2) +
"<br>";
}
}
Push(finalResults, { attributes: { Permits: textBlock } });
}
return FeatureSet(
{
fields: [{ name: "Permits", type: "esriFieldTypeString" }],
features: finalResults
}
); Using my test data, the code produces this list
... View more
Tuesday
|
1
|
4
|
76
|
POST
|
This goes back to my previous post How you get the features variable depends on where you're using the Arcade code. It could be using the variable $datastore or $layer. Or you might need to get it from a function like FeatureSetByName or FeatureSetByPortalItem What happens when you use "$datastore"?
... View more
Tuesday
|
0
|
0
|
30
|
POST
|
The Distinct function for FeatureSets has the syntax Distinct(features, fields) with the "features" variable being a FeatureSet and the "fields" variable being either a single field name or an array of field names. How you get the features variable depends on where you're using the Arcade code. It could be using the variable $datastore or $layer. Or you might need to get it from a function like FeatureSetByName or FeatureSetByPortalItem What do you get if you use this in your code? Distinct($layer, "Peferisana starost")
... View more
Friday
|
0
|
0
|
271
|
POST
|
What are you trying to do with this code? This affects what profile variables and functions you're able to use in your code. For example, labeling and visualization gives you a very limited set of profile variables and function bundles for efficiency reasons, whereas field calculations and popups give you more. In any case, you can't use "$Kartirane geoloske jedinice", since that is not a FeatureSet variable.
... View more
Friday
|
0
|
0
|
284
|
POST
|
You're using the incorrect syntax for the Distinct function for a FeatureSet. It should be Distinct($layer, 'fieldName')
//or
Distinct($layer, ['fieldName1', 'fieldName2'])
... View more
a week ago
|
2
|
0
|
343
|
POST
|
There are a couple of ways to do that. You can put a simple IIf function in the backgroundColor property to change it if it's a certain value. return {
cells: {
Portfolio_1: {
displayText : Text($datapoint.Portfolio_1),
textColor: '',
backgroundColor: iif($datapoint.Portfolio_1 == 1, "#ff0000",""),
textAlign: 'right',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
}, which will give you this If you want to apply that logic to several columns, a better way would be to use a function that determines whether the cell should have a red background color, using the value of the $datapoints of the various columns. function bgColor(input) {
if (input == 1) return "#ff0000"
}
return {
cells: {
Portfolio_1: {
displayText : Text($datapoint.Portfolio_1),
textColor: '',
backgroundColor: bgColor($datapoint.Portfolio_1),
textAlign: 'right',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
Portfolio_2: {
displayText : Text($datapoint.Portfolio_2),
textColor: '',
backgroundColor: bgColor($datapoint.Portfolio_2),
textAlign: 'right',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
Portfolio_3: {
displayText : Text($datapoint.Portfolio_3),
textColor: '',
backgroundColor: bgColor($datapoint.Portfolio_3),
textAlign: 'right',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
Portfolio_4: {
displayText : Text($datapoint.Portfolio_4),
textColor: '',
backgroundColor: bgColor($datapoint.Portfolio_4),
textAlign: 'right',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
Portfolio_5: {
displayText : Text($datapoint.Portfolio_5),
textColor: '',
backgroundColor: bgColor($datapoint.Portfolio_5),
textAlign: 'right',
iconName: '',
iconAlign: '',
iconColor: '',
iconOutlineColor: ''
},
}
} which results in this
... View more
a week ago
|
1
|
0
|
66
|
Title | Kudos | Posted |
---|---|---|
1 | yesterday | |
1 | Tuesday | |
1 | a week ago | |
2 | a week ago | |
1 | a week ago |
Online Status |
Offline
|
Date Last Visited |
10 hours ago
|