|
POST
|
You could create an array of DateOnly holidays and test whether today as a DateOnly is in that array var holidays = [
DateOnly(2025, 0, 1), //Months are 0-based
DateOnly(2025, 0, 20),
DateOnly(2025, 1, 17),
etc...
];
if (Includes(holidays, DateOnly())) {
return "Closed (Federal holiday)";
} else {
iif(current >= start && current <= end, "Open now", "Closed");
}
... View more
06-27-2025
10:02 AM
|
1
|
0
|
1406
|
|
POST
|
If you had one entry per year in your data, you could have used the same GroupBy to create the two new columns dividing the sum of the federal (or local) investments by the sum of all investments. However, that won't work with multiple rows per year. Instead you take the grouped FeatureSet and run another GroupBy to calculate those numbers. var grouped = GroupBy(fs,"Year",
[
{
name: "Fed_Funding",
expression: "Fed_Fund_1 + Fed_Fund_2 + Fed_Fund_3",
statistic: "SUM"
},
{
name: "Local_Funding",
expression: "Local_Fund_1 + Local_Fund_2 + Local_Fund_3 + Local_Fund_4",
statistic: "SUM"
}
]
);
GroupBy(grouped, "Year",
[
{ name: "Federal Funding", expression: "Fed_Funding", statistic: "Max" },
{ name: "Local Funding", expression: "Local_Funding", statistic: "Max" },
{
name: "Total Investment",
expression: "Fed_Funding + Local_Funding",
statistic: "Max"
},
{
name: "Federal Percentage",
expression: "Fed_Funding/(Fed_Funding + Local_Funding)",
statistic: "Max"
},
{
name: "Local Percentage",
expression: "Local_Funding/(Fed_Funding + Local_Funding)",
statistic: "Max"
}
]
);
... View more
06-27-2025
09:24 AM
|
0
|
2
|
730
|
|
POST
|
And for the bonus, you can add a filter // Fetches features from a public portal item
var fs = FeatureSetByPortalItem(
Portal("https://xyz.maps.arcgis.com/"),
"xyz",
0,
["Year", "Program_Type", "Fed_Fund_1", "Fed_Fund_2", "Fed_Fund_3", "Local_Fund_1", "Local_Fund_2", "Local_Fund_3", "Local_Fund_4"],
false
);
var filtered = Filter(fs, "Program_Type <> 'Program Orange'")
return GroupBy(filtered, "Year", [
{
name: "Fed_Funding",
expression: "Fed_Fund_1 + Fed_Fund_2 + Fed_Fund_3",
statistic: "SUM"
}, {
name: "Local_Funding",
expression: "Local_Fund_1 + Local_Fund_2 + Local_Fund_3 + Local_Fund_4",
statistic: "SUM"
}
]);
... View more
06-27-2025
07:01 AM
|
2
|
5
|
741
|
|
POST
|
When you add an element to the dashboard, you have the choice of selecting a layer or a data expression. If it's an empty dashboard, you'll be present with this dialog If you're using an existing dashboard, you'll see something like this dialog In either case, click "New data expression" to add your Arcade code.
... View more
06-26-2025
12:39 PM
|
2
|
0
|
839
|
|
POST
|
You can do this with a data expression that would supply a FeatureSet to the chart. In the data expression, you would fetch the data set and use the Sum function expression for each field and add them up. Then you would put those values into a new FeatureSet (since a data expression needs to return a FeatureSet). That would look something like this // Fetches features from a public portal item
var fs = FeatureSetByPortalItem(
Portal("yourPortal"),
"yourItem",
0,
["Fed1", "Fed2", "Local1", "Local2", "Local3"],
false
);
var fed = Round(Sum(fs, "Fed1") + Sum(fs, "Fed2"), 2);
var local = Round(Sum(fs, "Local1") + Sum(fs, "Local2") + Sum(fs, "Local3"), 2);
return FeatureSet(
{
fields: [
{ name: "Federal", type: "esriFieldTypeSingle" },
{ name: "Local", type: "esriFieldTypeSingle" }
],
features: [{
attributes: {Federal: fed, Local: local}
}]
}
);
... View more
06-26-2025
12:23 PM
|
0
|
2
|
842
|
|
POST
|
Can you provide screen shots of your data? And do you want to show the fields as a comma-separated string ("Field1, field2") or a field list like this?
... View more
06-25-2025
08:46 AM
|
0
|
2
|
390
|
|
POST
|
This solution uses template literals and an implicit return IIf(
$feature.province_code > 59,
`${$feature.both_rate_12}, ${$feature.both_rate_10}`,
`${$feature.both_rate_6}, ${$feature.both_rate_4}`
);
... View more
06-25-2025
07:47 AM
|
1
|
4
|
439
|
|
POST
|
Use the Pow function to raise x to the power of y var D = 0.7;
if (IsEmpty(D)) return null;
return Pow(D - .62, 2.48) * 2.49 * 448.8;
... View more
06-24-2025
12:40 PM
|
2
|
0
|
460
|
|
POST
|
You are returning a Dictionary, not a FeatureSet. You just need to wrap that Dictionary in the FeatureSet function var capa = FeatureSetByPortalItem(
Portal(""),
"597723f82afb4031a8211a2a993c7688",
0,
["estado"]
);
var total = Count(capa);
var rechazadas = Count(Filter(capa, "estado = 'Rechazada IPEEM/Archivo'"));
var porcentaje = IIf(total == 0, 0, Round(rechazadas / total * 100, 1));
return FeatureSet(
{
fields: [{ name: "porcentaje", type: "esriFieldTypeDouble" }],
geometryType: "",
features: [{ attributes: { porcentaje: porcentaje } }]
}
);
... View more
06-23-2025
07:50 AM
|
1
|
0
|
676
|
|
POST
|
It would help if you provide the code. Are you trying to access fields that don't exist in that particular layer?
... View more
06-23-2025
07:04 AM
|
0
|
1
|
515
|
|
POST
|
There are a few things that need to be fixed in your code. The TypeOf documentation seems to be incorrect. It returns "String" instead of "Text" for text. (line 15) Use "Count" instead of "Length" to return the length of a string (lines 20, 21, and 28) // barcode variable from feature attribute
var barcodeValue = 'BTR7981006';
Console('Barcode Value: ' + barcodeValue);
// Define valid prefixes for Bin
var validPrefixes = [
'BTR75', 'BTR76', 'BTR780', 'BTR781', 'BTR7820', 'BTR7821', 'BTR7831',
'BTR7846', 'BTR7847', 'BTR7848', 'BTR7855', 'BTR7866', 'BTR789', 'BTR790',
'BTR792', 'BTR798'
];
var isValid = false;
// Check if barcode is empty or not a text value
if (IsEmpty(barcodeValue) || TypeOf(barcodeValue) != 'String') {
Console('Failed: Empty or non-text');
isValid = false;
}
// Check if barcode starts with BTR and is 10 characters long
else if (Left(barcodeValue, 3) != 'BTR' || Count(barcodeValue) != 10) {
Console('Failed: Invalid format, BTR=' + Left(barcodeValue, 3) + ', Length=' + Text(Count(barcodeValue)));
isValid = false;
}
// Check if barcode starts with any valid prefix
else {
for (var prefixIndex in validPrefixes) {
var currentPrefix = validPrefixes[prefixIndex];
if (Left(barcodeValue, Count(currentPrefix)) == currentPrefix) {
Console('Passed: Matched prefix ' + currentPrefix);
isValid = true;
break;
}
}
}
// Return validation result
Console('Result: ' + Text(isValid));
return isValid;
... View more
06-18-2025
05:19 AM
|
1
|
2
|
469
|
|
POST
|
Which version of ArcGIS Pro are you using? According to the documentation, $view was implemented in Arcade 1.30. In the version matrix, this version is available in ArcGIS Pro 3.5 only.
... View more
06-13-2025
11:10 AM
|
0
|
2
|
517
|
|
POST
|
The advanced formatting tool is designed to format individual values (an indicator result or an item in a list), not calculating values from an entire featureset. What you'll need to do write a data expression for the indicator that will calculate that average. You would use your formatting function in the indicator's advanced formatting section. Your data expression would look something like this var fs = FeatureSetByPortalItem(
Portal("yourPortalUrl"),
"yourItemId",
0,
["DateTimeInit", "DateTimeClosed"],
false
);
var responseTime = 0;
var counter = 0;
for (var f in fs) {
var dateOpened = f.DateTimeInit;
var dateCleared = f.DateTimeClosed;
if (!IsEmpty(dateOpened) && !IsEmpty(dateCleared)) {
responseTime += DateDiff(dateCleared, dateOpened, "seconds");
counter += 1;
}
}
return FeatureSet(
{
fields: [{ name: "Average", type: "esriFieldTypeInteger" }],
features: [{ attributes: { Average: Round(responseTime / counter) } }]
}
);
... View more
06-13-2025
11:04 AM
|
0
|
0
|
923
|
|
POST
|
Can you post your code using the Insert/Edit code sample button? Trying to decipher code in an image is too difficult, especially when attempting to test your code.
... View more
06-13-2025
09:42 AM
|
0
|
0
|
949
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 4 weeks ago | |
| 2 | 4 weeks ago | |
| 1 | 11-18-2025 12:30 PM | |
| 2 | 11-18-2025 06:53 AM | |
| 1 | 11-17-2025 06:38 AM |
| Online Status |
Online
|
| Date Last Visited |
9 hours ago
|