Calculate Fields for Text values

1280
6
08-31-2023 06:49 AM
EuropaxEarth
Regular Contributor

Hello,

I'm curious to know if there is a workaround to using the 'Calculate Fields' tool for text values. 

So far, I haven't been able to find any documentation confirming that this is possible in ArcGISPro. 

0 Kudos
6 Replies
SarahRijneke
Frequent Contributor

What exactly are you trying to do? attribute rules are handy if you're looking to automatically populate values when features are updated or created. 

0 Kudos
EuropaxEarth
Regular Contributor

I am trying to discern what parcels do and do not contain brownfields. There are two brownfield datasets that I am referencing.

There can be three outcomes:

* A parcel contains Brownfield Dataset A

*A Parcel contains Brownfield Dataset B 

* A parcel contains BOTH Datasets.

For example, I use select by location to see what parcels contain Brownfield A. With that selection, I use calculate fields to say "Brownfields = A".

Then I go in and do select by location to see what parcels contain Brownfield B. Half of the parcels in that selection happen to also contain Brownfield A.

However, when I use calculate fields to have "Brownfields = B", it OVERWRITES, my previous calculations making me unable to display parcels that contain BOTH parcels A and B in my attribute table.

I attempted to use the code below to fill in all the "NULL" values with B, and then replace all the "A" parcels that also contain Brownfield B with "A and B".

if (Brownfields == NULL):
return ' "B" '
else:
return '"A and B"'

However, because my "Brownfields" field is a text data type, this script was unsuccessful.

Essentially, I would like to know how to overwrite previous calculations to display multiple values in within one cell.

0 Kudos
SarahRijneke
Frequent Contributor

I haven't tested it, but this might work assuming all of your data is in the same geodatabase. Open field calculator and switch the expression type to Arcade & copy/paste the following code. Make sure to change 'Brownfield A' and 'Brownfield B' to the names of the parcel feature layers in your map.

 

 

var BrownA = FeatureSetByName($map,'Brownfield A');
var BrownB = FeatureSetByName($map,'Brownfield B');
var Both = Intersects(BrownA, BrownB);

if (Intersects($feature, BrownA)){
return “A”}
if (Intersects($feature, BrownB)){
return “B”}
if (Intersects($feature, Both)){
return “A and B”}

 

 

 

0 Kudos
AyanPalit
Esri Regular Contributor

@EuropaxEarth Refer to:

Calculate Field using Python

Fundamentals of field calculations

Ayan Palit | Principal Consultant Esri
0 Kudos
TristenDenton4
Regular Contributor

What's the text you're trying to populate?

 

0 Kudos
EuropaxEarth
Regular Contributor

Posted this above, but I'll recopy it here!

 

I am trying to discern what parcels do and do not contain brownfields. There are two brownfield datasets that I am referencing.

There can be three outcomes:

* A parcel contains Brownfield Dataset A

*A Parcel contains Brownfield Dataset B 

* A parcel contains BOTH Datasets.

For example, I use select by location to see what parcels contain Brownfield A. With that selection, I use calculate fields to say "Brownfields = A".

Then I go in and do select by location to see what parcels contain Brownfield B. Half of the parcels in that selection happen to also contain Brownfield A.

However, when I use calculate fields to have "Brownfields = B", it OVERWRITES, my previous calculations making me unable to display parcels that contain BOTH parcels A and B in my attribute table.

I attempted to use the code below to fill in all the "NULL" values with B, and then replace all the "A" parcels that also contain Brownfield B with "A and B".

if (Brownfields == NULL):
return ' "B" '
else:
return '"A and B"'

However, because my "Brownfields" field is a text data type, this script was unsuccessful.

Essentially, I would like to know how to overwrite previous calculations to display multiple values in within one cell.

0 Kudos