Need Help With Arcade Sum() Expression

3328
8
01-16-2019 11:05 AM
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I'm new to Arcade. I'm trying to summarize square footage for rooms of a certain classification (containing the prefix 'CR_') in a Map Series using dynamic text. The expression builder says my Arcade expression is valid, but nothing is being printed to the dynamic text box. 

0 Kudos
8 Replies
WendyHarrison
Esri Contributor

Hi Levi,

you'll need to rework the return line.  The sum should be an element in the array, not the second parameter in concatenate.

Concatenate( [ "Total: ", Sum(sqft) ] )

or cast the sum to text

Concatenate( [ "Total: ", Text(Sum(sqft)) ] )

----------------

does your UsableArea field contain a list of values that you're summing?  or are you trying to do something else?

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

No, I'm trying to create a single sum for all features that contain the text prefix 'CR_'. I've been reading that Arcade can't be used on multiple records??? What is the point? I could accomplish this in seconds in Python, but I can only use Arcade expressions for Dynamic text in a Map Series. 

0 Kudos
WendyHarrison
Esri Contributor

To do that you need access to FeatureSet to loop through features.  The dynamic text expressions are part of the Visualization profile and don't have access to this functionality.  There is another way to do what you're looking for through dynamic text.  I've spoken with a colleague and she'll be here shortly to take you through it.

thanks

Wendy

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

Cool, thanks!

0 Kudos
XanderBakker
Esri Esteemed Contributor

I think  would first you the Filter function to get the list of records that start with CR_ and then apply the sum to that list.

0 Kudos
AubriKinghorn
Esri Regular Contributor

Hi Levi,

To get the result you want, you want to use Table Statistic dynamic text instead of Table Attribute. This type of dynamic text allows you to pick a field within your data to calculate a statistic on. You can refine the calculation to use All Rows, Visible Rows, Map Series Rows, or a Custom SQL query. You can then add additional static text to your text element, instead of using Concatenate. 

This help topic Add dynamic text—Layouts | ArcGIS Desktop has some more information on Table Statistic and Table Attribute dynamic text types and when to use each.

Cheers,

Aubrianna

Cheers,
Aubri
0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

That was the first approach I tried, but I just figured out what the problem was. I needed a definition query on the layer itself that filters out rooms that don't meet the criteria. Then I can have table statistic dynamic text that sums just those values. 

0 Kudos
by Anonymous User
Not applicable

Is it possible to create a query that performs a calculation and then produces the sum of that calculation? In my map layout I would like to display the total length of roads driven for "Red Route" but in order to calculate the total length I first need to multiply the length field by the number of lanes that exist for each road (without storing this in the attribute table). Currently I have been able to display the total by number of lanes (dynamic text: table statistics):

SHartholt_2-1670937981253.png

 

Or the lane distance for each feature (dynamic text: table attribute):

SHartholt_0-1670937343873.png

but I can't seem to produce the grand total.

 

0 Kudos