Select to view content in your preferred language

Dashboard Arcade expression to use data from 2 fields for a List Element

762
2
Jump to solution
01-10-2024 10:24 AM
Labels (1)
JohnEsch1
Occasional Contributor

I have an ArcGIS Dashboard and a List element where I want to use 2 separate fields: called {Well_Name} and  {FacilityName}. By just putting in both fields I get an unsatisfactory list, where if there is not a Well_Name attribute, but a FacilityName attribute, it puts a NA in front of the FacilityName. The opposite occurs if there is Well_Name attribute, but not a FacilityName, by putting a N/A after the Well_Name. There must be a way to populate a List element from 2 separate fields. Would this be easier as an Arcade expression in the web map popup or in the Dashboard? 

JohnEsch1_0-1704910116075.png

JohnEsch1_1-1704910278719.png

 

0 Kudos
1 Solution

Accepted Solutions
marksm_macomb
Frequent Contributor

If you click "Enable" in the advanced formatting section, you can create your own arcade variables to use in your list. So if it's a case where both names could be populated, it might look something like:

 

var wellNameFormatted = Iif($datapoint.Well_Name == "N/A", "", $datapoint.Well_Name)
var facilityNameFormatted = Iif($datapoint.FacilityName == "N/A", "", $datapoint.FacilityName)

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
   attributes: {
     Well: wellNameFormatted,
     Facility: facilityNameFormatted
   }
}

 

And then you would reference it in your list as {expression/Well}{expression/Facility}

Or if it's only possible for one or the other to have a name, you could do it with one variable like this:

var nameFormatted = Iif($datapoint.Well_Name == "N/A", $datapoint.FacilityName, $datapoint.Well_Name)

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
   attributes: {
     Name: nameFormatted
   }
}

And just reference {expression/Name}

View solution in original post

2 Replies
marksm_macomb
Frequent Contributor

If you click "Enable" in the advanced formatting section, you can create your own arcade variables to use in your list. So if it's a case where both names could be populated, it might look something like:

 

var wellNameFormatted = Iif($datapoint.Well_Name == "N/A", "", $datapoint.Well_Name)
var facilityNameFormatted = Iif($datapoint.FacilityName == "N/A", "", $datapoint.FacilityName)

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
   attributes: {
     Well: wellNameFormatted,
     Facility: facilityNameFormatted
   }
}

 

And then you would reference it in your list as {expression/Well}{expression/Facility}

Or if it's only possible for one or the other to have a name, you could do it with one variable like this:

var nameFormatted = Iif($datapoint.Well_Name == "N/A", $datapoint.FacilityName, $datapoint.Well_Name)

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
   attributes: {
     Name: nameFormatted
   }
}

And just reference {expression/Name}

JohnEsch1
Occasional Contributor

Thank you very much, it worked like a charm!

JohnEsch1_0-1704917794501.png