Select to view content in your preferred language

Need Help Writing an Arcade script for Expression for Serial Chart

70
5
Jump to solution
Friday
Labels (1)
BrianHartz_Lumos
Emerging Contributor

I'm working on developing a dashboard for high level people within our organization. Currently, we have a field (RoadCL_FT) that is a Double data type field. I need to write an Arcade script that will allow me to add 30% to all the records in that field. Any suggestions? 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You can use the GroupBy function to add 30% to a field. Here's an example from the Playground

code.png

 

// Fetches features from a public portal item
var fs = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  // portal item id
  "6200db0b80de4341ae8ee2b62d606e67",
  0, // layer id
  ["*"], // fields to include
  true // include or exclude geometry
);

GroupBy(fs, 'BUILDINGID', [{ name: 'Base Elevation', expression: 'BASEELEV', statistic: 'MAX' },
  { name: 'New Base Elevation', expression: 'BASEELEV * 1.3', statistic: 'MAX' }])

 

 

View solution in original post

5 Replies
KenBuja
MVP Esteemed Contributor

You can use the GroupBy function to add 30% to a field. Here's an example from the Playground

code.png

 

// Fetches features from a public portal item
var fs = FeatureSetByPortalItem(
  Portal("https://www.arcgis.com"),
  // portal item id
  "6200db0b80de4341ae8ee2b62d606e67",
  0, // layer id
  ["*"], // fields to include
  true // include or exclude geometry
);

GroupBy(fs, 'BUILDINGID', [{ name: 'Base Elevation', expression: 'BASEELEV', statistic: 'MAX' },
  { name: 'New Base Elevation', expression: 'BASEELEV * 1.3', statistic: 'MAX' }])

 

 

BrianHartz_Lumos
Emerging Contributor

I had to make a couple of adjustments to what you sent me, but it was what I needed to achieve the goal. Thank you for the assist!!

0 Kudos
BrianHartz_Lumos
Emerging Contributor

Do I need to create a new field for the data to be populated in?

0 Kudos
KenBuja
MVP Esteemed Contributor

No, you don't need to. The GroupBy function creates the new FeatureSet that you can use in your serial chart. In the code above, I added as the output both the original field and the calculated field with the 30% added, but just to compare the field. You could just include the calculated field without the original field.

0 Kudos
BrianHartz_Lumos
Emerging Contributor

Then layer that I'm trying to work with is a layer that is in a group layer or dataset. Would I plug in the ID of the group then try to limit it to the layer name?

0 Kudos