Select to view content in your preferred language

ArcGIS Dashboards Indicator Attribute Expression to Sum across fields with conditions

309
6
Jump to solution
02-12-2025 11:30 AM
Labels (1)
LJackson29
Frequent Contributor

Hello - I am working in ArcGIS Online Dashboards. My dashboard already has a data expression to create some necessary fields with data at the feature level. I am trying to create an attribute expression for an indicator that sums data across 4 fields (A, B, C, and D below) selecting different features for each field depending upon a status field. Below is what I came up with, but it is not working. Any suggestions? TIA

 

var SUM_A=IIf($datapoint.status='Submitted', sum($datapoint.A),0)
var SUM_B=IIf($datapoint.status='Scored', sum($datapoint.B),0)
var SUM_C=IIf($datapoint.status='construction', sum($datapoint.C),0)
var SUM_D=IIf($datapoint.status='Complete', sum($datapoint.D),0)
var SUM_ABCD = SUM_A+SUM_B+SUM_C+SUM_D


return {
  //textColor:'',
  //backgroundColor:'',
  topText: 'Total Cost',
  //topTextColor: '',
  //topTextOutlineColor: '',
  //topTextMaxSize: 'medium',
  middleText: SUM_ABCD,
  middleTextColor: '',
  middleTextOutlineColor: '',
  middleTextMaxSize: 'large',
  //bottomText: '',
  //bottomTextColor: '',
  //bottomTextOutlineColor: '',
  //bottomTextMaxSize: 'medium',
  //iconName:'',
  //iconAlign:'left',
  //iconColor:'',
  //iconOutlineColor:'',
  //noValue:false,
  //attributes: {
    // attribute1: '',
    // attribute2: ''
  // }
}

  

0 Kudos
1 Solution

Accepted Solutions
DanielReynolds4
Occasional Contributor

I'm not really sure if there is a way to aggregate values from multiple features. You may need to create a new data expression to summarize the data.

View solution in original post

0 Kudos
6 Replies
DanielReynolds4
Occasional Contributor

On the Data tab in the indicator configuration, is the Value type set to Statistic or Feature? I think if it is set to Statistic, the indicator only has access to the field selected for the statistic calculation. I think if you change it to Feature, it might work.

DanielReynolds4_0-1739402673832.png

 

0 Kudos
LJackson29
Frequent Contributor

@DanielReynolds4 It is set to statistic. This is more complicated than summing one field. I need to sum data across 4 different fields with each having a different subset of records. See the attribute expression able for what I am trying to do. If it was just two fields I could use the statistic/sum option along with the reference/sum option, but I have 4 fields.

0 Kudos
DanielReynolds4
Occasional Contributor

When I was testing this, I found that if Statistic was selected on the Data tab, only the field selected for the statistic calculation was available in the attribute expression editor. If Feature is selected on the Data tab, all fields are available for the datapoint. What I mean by a field being available in the attribute expression editor may not be clear, so let me clarify that. What I mean is that when you expand the attribute expression editor using the 'Pop out editor' button next to the 'Delete expression' button, you can then access hints for Profile variables by clicking the (x) button. If you expand the $datapoint entry, it will show you the variables that you have access to.

My guess is that having Statistic selected limits the values available for use in the attribute expression, preventing the expression from executing properly even if you have correctly specified the fields you want to pull values from.

0 Kudos
LJackson29
Frequent Contributor

@DanielReynolds4 I apologize for mis-reading your first message. I changed it to Feature, and I don't have any errors in the code, but unfortunately, it does not show the summed value in the indicator, but the value for the first feature in Field A, I think because it is set to "feature". Any other thoughts?

0 Kudos
DanielReynolds4
Occasional Contributor

I'm not really sure if there is a way to aggregate values from multiple features. You may need to create a new data expression to summarize the data.

0 Kudos
LJackson29
Frequent Contributor

@DanielReynolds4 Thanks. Unfortunately I have filters that the indicator needs to work with and a 2nd data expression that would be summary data would make that difficult I think.

0 Kudos