I am attempting to create an arcade code that will censor data in a serial chart on a dashboard. I am very new to arcade and there seems to be little information on how to do this or if this is possible. From lots of research I have put together some code, but the layer is marked as "unable to execute arcade script." Any tips or critiques of what I have or where I can find examples of what I am trying to do are much appreciated!
My code is below:
var fsportal = Portal("https://www.arcgis.com/");
var fs = FeatureSetByPortalItem(fsportal, "dfc071575e924d5d88cb851eab914222", 0, ['Total_Daily_Cases','Hispanic_or_Latino',
'Not_Hispanic_or_Latino', 'Unknown_Ethnicity', 'Ethnicity_Not_Reported',
'Black_or_African_American', 'White_Race', 'Other_Race',
'Native_Hawaiian_or_Other_Pacific_Islander_Race', 'Asian_Race',
'American_Indian_or_Alaskan_Native_Race', 'Unknown_Race',
'Race_Not_Reported','Unknown_Age_Group', '00_17_Age_Group',
'18_29_Age_Group','30_39_Age_Group','40_49_Age_Group',
'50_64_Age_Group','65_74_Age_Group','75__Age_Group','Year', false]);
if (IsEmpty(fs)) {
return "No data available for this query.";
} else {
return "Feature Set successfully retrieved.";
}
var cnsrvalue = feature(fs,'Total_Daily_Cases')
if (cnsrvalue <= 5) {
return "suppressed";
} else {
return Text(cnsrvalue); // Return the actual value as a string
}
var CnsrDict = {
fields: [
{name: 'Total_Daily_Cases', type: 'esriFieldTypeInteger'},
{name: 'Hispanic_or_Latino', type: 'esriFieldTypeInteger'},
{name: 'Not_Hispanic_or_Latino', type: 'esriFieldTypeInteger'},
{name: 'Unknown_Ethnicity', type: 'esriFieldTypeInteger'},
{name: 'Ethnicity_Not_Reported', type: 'esriFieldTypeInteger'},
{name: 'Black_or_African_American', type: 'esriFieldTypeInteger'},
{name: 'White_Race', type: 'esriFieldTypeInteger'},
{name: 'Other_Race', type: 'esriFieldTypeInteger'},
{name: 'Native_Hawaiian_or_Other_Pacific_Islander_Race', type: 'esriFieldTypeInteger'},
{name: 'Asian_Race', type: 'esriFieldTypeInteger'},
{name: 'American_Indian_or_Alaskan_Native_Race', type: 'esriFieldTypeInteger'},
{name: 'Unknown_Race', type: 'esriFieldTypeInteger'},
{name: 'Race_Not_Reported', type: 'esriFieldTypeInteger'},
{name: 'Unknown_Age_Group', type: 'esriFieldTypeInteger'},
{name: '00_17_Age_Group', type: 'esriFieldTypeInteger'},
{name: '18_29_Age_Group', type: 'esriFieldTypeInteger'},
{name: '30_39_Age_Group', type: 'esriFieldTypeInteger'},
{name: '40_49_Age_Group', type: 'esriFieldTypeInteger'},
{name: '50_64_Age_Group', type: 'esriFieldTypeInteger'},
{name: '65_74_Age_Group', type: 'esriFieldTypeInteger'},
{name: '75__Age_Group', type: 'esriFieldTypeInteger'},
{name: 'Year', type: 'esriFieldTypeInteger'},
{name: 'cnsrvalue', type: 'esriFieldTypeString'}
]
};
var index = 0;
return Featureset(Text(CnsrDict));