Select to view content in your preferred language

# Help with Calculating Percentage

1623
4
02-21-2022 04:03 PM
by
Emerging Contributor

I am attempting to calculate the area of shade as opposed to no shade in an area.

I have created the table which has two objects: 'Shade' and 'No Shade'. I then have a field for the total area for both of these objects. I now want to calculate the percentage for these two objects. I have created a 'Percent' field and am now attempting to calculate the field. The total area for 'Shade' and 'No Shade' is 171,808.9.

The code I am running is: !SUM_Shape_Area! / 171,808.9 * 100

When I run this, I get no error messages, however the Percent field remains NULL.

While trying to figure out the issue, I ran a simpler code of !Sum_Shape_Area! / 2.

This ran fine and resulted in the Percent field simply having a value of half of the SUM_shape_area field.

Does anyone know why this percent calculation is not working?

Thanks!

1 Solution

Accepted Solutions
MVP Esteemed Contributor

Is see... try dumping the comma in the number, it is yielding unexpected results if python is being used

``````1000/1,000
(1000.0, 0)

1,000/1,000
(1, 0.0, 0)

1000/1000
1.0``````

... sort of retired...
4 Replies
MVP Esteemed Contributor

Are you doing this on a row by row basis?  it isn't clear from your question.

If you want if for the table, then see

Summary Statistics (Analysis)—ArcGIS Pro | Documentation

... sort of retired...
by
Emerging Contributor

I am attempting to calculate this for the table using the Calculate Field function from within the attribute table. I have attached photos of my code and the attribute table. I have seen others successfully calculate percentage for their tables using this method. I am just confused as to why the table is not responding correctly.

MVP Esteemed Contributor

Is see... try dumping the comma in the number, it is yielding unexpected results if python is being used

``````1000/1,000
(1000.0, 0)

1,000/1,000
(1, 0.0, 0)

1000/1000
1.0``````

... sort of retired...
by
Emerging Contributor

Thank you! Just a simple overlook on my part.