Hexagon Geospatial
MENU

M.App Enterprise

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
New Contributor
Posts: 5
Registered: ‎01-18-2018
Accepted Solution

JAVASCRIPT for SUM in Functional Attributes

Hi,

I'm trying to create and attribute [Unemployed Total] in Feature Analyzer from two records: Unemployed_M, Unemployed_M, both are smallint data type

 

return currentRecord["Unemployed_M"] + currentRecord["Unemployed_M"];

 

That seems to create a string containing both records, for example Unemployed_M=4, Unemployed_M=7, the total = 47 insterad of 11

When I use the same code but do the substraction: 

 

return currentRecord["Unemployed_M"] - currentRecord["Unemployed_M"];

 

I'm getting the correct total (-3).

 

Can somebody advice me on the correct script to get to sum two records please.

 

Kamila

Technical Evangelist
Posts: 908
Registered: ‎09-11-2015

Re: JAVASCRIPT for SUM in Functional Attributes

Hi Kamila,

 

According to the suggestions here:

https://stackoverflow.com/questions/22419222/javascript-numbers-concatenate-instead-of-adding-but-ty...

 

You could try this:

return currentRecord["Unemployed_M"]*1 + currentRecord["Unemployed_M"]*1;
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

New Contributor
Posts: 5
Registered: ‎01-18-2018

Re: JAVASCRIPT for SUM in Functional Attributes

Jan,

Thank you very much, that is the correct script.

Best Rgerads,

Kamila

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Development Ticket through our Development Ticket Portal.