I am creating a Dashboard with several different serial charts. My data has a length field in feet; I am not able to edit the data or add a field. I need to have a bar chart that displays the length in miles. Is there a way for me to calculate this within the serial chart?
Solved! Go to Solution.
Try this:
The best way to do this, without having to create a new field in the data, would be to use the Dashboard Arcade function to return a new feature layer in the dashboard, where the units are converted from feet to miles.
Do you have a snapshot of your data?
I can get one, what do you mean by a snapshot?
An example of your data - fields etc
It is a portal item, I was trying to do a FeatureSetByPortalItem but keep getting the error: Test execution error: ',' expected.. Verify test data.
I need to be able to acce the "Path_Rating" field and the "PATH_Length" field and I need calculate the "PATH_Length" field so that it is divided by 5280 to convert it to miles.
I see what you're getting at. Your need to create a new array and push the converted values into that array:
I really appreciate your help. I have tried to apply this and keep getting "Test execution error: Invalid variable assignment. Verify test data.
here is what I have put in:
You need to build an array to push the features in, which is var features = []; just after you connect to your portal, and you need to return the converted values (or whatever you will call your fs). See below:
var portal = Portal('https://arcgis.com');
// Provide the actual Portal Item ID and layer index
var fs = FeatureSetByPortalItem(portal, '<PORTAL_ITEM_ID>', 2, ['PATH_Length', 'Path_Rating_txt'], false);
// Initialize the output array
var features = [];
for (var f in fs) {
var lengthMiles = Round(f['PATH_Length'] / 5280, 2);
var pathRating = f['Path_Rating_txt'];
Push(features, {
attributes: {
lengthMiles: lengthMiles,
Path_Rating_txt: pathRating
}
});
}
var convertedValues= {
fields: [
{ name: 'Path_Rating_txt', type: 'esriFieldTypeString' },
{ name: 'lengthMiles', type: 'esriFieldTypeDouble' }
],
geometryType: '', // Define geometryType if needed (e.g., 'esriGeometryPoint')
features: features
};
return convertedValues;
This works when I run it in the data expression builder but when I close it I get "Unable to execute arcade script" when trying to select it to use in my serial layer.
Try this: