Select to view content in your preferred language

ArcGIS Dashboard Indicator advanced expression

144
2
Jump to solution
2 weeks ago
LJackson29
Frequent Contributor

Hello - I want to create an indicator that shows the best available project cost data pulling from 4 different fields based upon the status of the project. The indicator will show data from a new field (orig_asptotcost) using data from fields 1 and 2 based upon criteria 1, data from field 3 (PR_P6TOTCOST) based upon criteria 2, and data from field 4 (PR_EBSTOTCOST) based upon criteria 3. I figured out how to do this in ArcGIS Pro Field Calculator using arcade but not sure how to do it in advanced formatting for an indicator widget as there is not field in the database for this combined cost data. Any recommendations? Below is my code from Pro.

Thanks!

// combines data from field 1 and 2 into a single var
var orig_asptotcost=IIF($feature.PR_ASPTOTCOST>0, $feature.PR_ASPTOTCOST, $feature.PR_ORIGTOTCOST)

// when the below criteria are met, orig_asptotcost is displayed
if($feature.PR_Status=='01. Submitted – Pending Review/Scoring' || $feature.PR_Status=='02. Scored' || $feature.PR_Status=='03. Advanced SW Planning'){

return round(orig_asptotcost,2);

//when the below criteria are met, data from PR_P6TOTCOST is displayed 
} else if ($feature.PR_Status=='04. Design' || $feature.PR_Status=='05. Construction') {

return round($feature.PR_P6TOTCOST,2);

//when the below criteria are met, data from PR_EBSTOTCOST is displayed
} else if ($feature.PR_Status=='07. Completed'){

return round($feature.PR_EBSTOTCOST,2);
}

 

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

For the advanced formatting code, you'll substitute $datapoint for $feature. You'll have to create a variable for your calculation that you will use in the return section.

var cost;
// combines data from field 1 and 2 into a single var
var orig_asptotcost = IIF($datapoint.PR_ASPTOTCOST > 0, $datapoint.PR_ASPTOTCOST, $datapoint.PR_ORIGTOTCOST)

// when the below criteria are met, orig_asptotcost is displayed
if($datapoint.PR_Status == '01. Submitted – Pending Review/Scoring' || $datapoint.PR_Status == '02. Scored' || $datapoint.PR_Status == '03. Advanced SW Planning'){
  cost = round(orig_asptotcost, 2);

//when the below criteria are met, data from PR_P6TOTCOST is displayed 
} else if ($datapoint.PR_Status == '04. Design' || $datapoint.PR_Status == '05. Construction') {
  cost = round($feature.PR_P6TOTCOST, 2);

//when the below criteria are met, data from PR_EBSTOTCOST is displayed
} else if ($datapoint.PR_Status == '07. Completed'){
  cost = round($datapoint.PR_EBSTOTCOST, 2);
}

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

Since orig_asptotcost is only needed in the first if evaluation, you could move that calculation within that section.

var cost;
// when the below criteria are met, orig_asptotcost is displayed
if($datapoint.PR_Status == '01. Submitted – Pending Review/Scoring' || $datapoint.PR_Status == '02. Scored' || $datapoint.PR_Status == '03. Advanced SW Planning'){
  cost = round(IIF($datapoint.PR_ASPTOTCOST > 0, $datapoint.PR_ASPTOTCOST, $datapoint.PR_ORIGTOTCOST), 2);

//etc

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

For the advanced formatting code, you'll substitute $datapoint for $feature. You'll have to create a variable for your calculation that you will use in the return section.

var cost;
// combines data from field 1 and 2 into a single var
var orig_asptotcost = IIF($datapoint.PR_ASPTOTCOST > 0, $datapoint.PR_ASPTOTCOST, $datapoint.PR_ORIGTOTCOST)

// when the below criteria are met, orig_asptotcost is displayed
if($datapoint.PR_Status == '01. Submitted – Pending Review/Scoring' || $datapoint.PR_Status == '02. Scored' || $datapoint.PR_Status == '03. Advanced SW Planning'){
  cost = round(orig_asptotcost, 2);

//when the below criteria are met, data from PR_P6TOTCOST is displayed 
} else if ($datapoint.PR_Status == '04. Design' || $datapoint.PR_Status == '05. Construction') {
  cost = round($feature.PR_P6TOTCOST, 2);

//when the below criteria are met, data from PR_EBSTOTCOST is displayed
} else if ($datapoint.PR_Status == '07. Completed'){
  cost = round($datapoint.PR_EBSTOTCOST, 2);
}

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

Since orig_asptotcost is only needed in the first if evaluation, you could move that calculation within that section.

var cost;
// when the below criteria are met, orig_asptotcost is displayed
if($datapoint.PR_Status == '01. Submitted – Pending Review/Scoring' || $datapoint.PR_Status == '02. Scored' || $datapoint.PR_Status == '03. Advanced SW Planning'){
  cost = round(IIF($datapoint.PR_ASPTOTCOST > 0, $datapoint.PR_ASPTOTCOST, $datapoint.PR_ORIGTOTCOST), 2);

//etc
0 Kudos
LJackson29
Frequent Contributor

@KenBuja Thank you!!! That was a lot easier than I realized - I didn't know you could replace the "return" statement with "fieldname=". Yay!

0 Kudos