Calculate Values using Dynamic Text

6358
11
02-17-2020 05:41 PM
FPCWAGIS_Admin
Occasional Contributor

Hi brains trust. I'm hoping someone can guide me here. Is it possible to use Dynamic Text in ArcGIS Pro to return the SUM of values in an attribute table (got this bit down pat) and then calculate/format a display value. 

For example, I run the SUM function on the Shape_Area field and it returns metres squared but I want to display it as Hectares. In labeling scripts this would be done like this using VB script:  formatnumber(Shape_Area\10000, 1). 

Another calculation I'd like to do is take the SUM and multiple by 0.5 or 0.3 to get a percentage of the SUM. 

An extension to this is, can separate values in dynamic text be added together to get a total (i.e. SUM A, plus SUM B = Total)?

0 Kudos
11 Replies
RickeyFight
MVP Regular Contributor
0 Kudos
FPCWAGIS_Admin
Occasional Contributor

No I hadn't, but it's not labels that I'm trying to create. I'm trying to create Dynamic Text in the Layout (i.e. A statistics summary in the legend area with Sums of different area values with calculations applied)

0 Kudos
RickeyFight
MVP Regular Contributor

FPCWA GIS Admin

I am assuming you are using arcgis pro.

Are you summing multiple polygons at once? 

have you looked here

Modify dynamic text—Layouts | Documentation 

0 Kudos
FPCWAGIS_Admin
Occasional Contributor

Hi Rickey. Yep - using ArcGIS Pro 2.5. It is summing multiple polygons based on the Shape_Area field (m2). I was hoping to be able to calculate some features to be a percentage of the value in the Shape_Area field based on categories in a different field (i.e. Category = 30% would result in Shape_Area x 0.3 for that row only). I don't think it is quite there yet from what I can find. Might have to try using Model Builder to generate a statistics table or something in the layout. 

0 Kudos
BrettGovernanti1
Regular Contributor

Hi you might have figured something out but if not, I was wanting to do something similar, but instead to modify the dynamic text of a summed ShapeLength field in feet to show that sum in miles. I'm using Pro 2.8.3 and added a dynamic text for Sum. Once created get into the dynamic text Format Text window and modify the plain text after after the field="SHAPE_Length" portion of the dynamic text code and enter your conversion factor. Next click the Tag View for it to take. Here's mine:

Day Segment Sum: <dyn type="table" property="sum" mapFrame="Monday Frame Map Frame" mapMemberUri="CIMPATH=friday_small_frame_2/residential_routes_jw_6_fri_2.xml" field="SHAPE_Length * 0.00018939" decimalPlaces="2" separator="true"/> miles

Walla!

LindsayRaabe_FPCWA
Honored Contributor

Hi @BrettGovernanti1 I've just seen your reply (posted the thread using the wrong account so didn't get notified. I just tried out your suggestion and it works well. Can't remember what the original use case-problem was but this definitely works well. 

Funnily enough though, when setting up the little test I did, the SUM dynamic text element was very unpredictable. When setting it to Visible rows, it would show the total of all rows still, but as soon as I added in the /1000 to convert to Kilometres, it would show the correct visible only figure. Tried a number of ways to get it to show what it should depending on the settings, but only the modified version of the text returned an accurate result. 

Lindsay Raabe
GIS Officer
Forest Products Commission WA
0 Kudos
WDMParkPlanner
Occasional Contributor

I am trying to follow and figure out how to sum a field for a feature class via dynamic type. I have tried inputting what you have and updating it with my info, however, I am lost as to what the "mapMemberUri...xml" represents and how I obtain that.  Thank you!

0 Kudos
LindsayRaabe_FPCWA
Honored Contributor

I believe thats the bit of the code that tells it which map frame to look at. If you create a dynamic text element (any type will do) and then look at it in the Tag View, you should be able to see/copy the reference to your map frame. 

Lindsay Raabe
GIS Officer
Forest Products Commission WA
0 Kudos
LukeGilner1
Frequent Contributor

@BrettGovernanti1 - your workflow worked perfectly!  That should be marked as the solution to the original post.

@LindsayRaabe_FPCWA - strange occurrence you were having.  One of my workflows for layouts uses a definition query on the necessary layer and then the All Rows option shows what I need.  Maybe that would help in your situation?