Skip to main content
Good morning everyone,

 

 

I have ArcGIS data traveling through many transformers. Just before it hits the writer I want to calculate 2 fields (PERCENT_WORKING_INTEREST and UNIT_LEASED_PERCENTAGE) based on other fields that reside in the same set of data about to be written to either a file geodatabase or SDE. I'm having a hard time finding a way to do this properly. It seems it should be easy. ExpressionEvaluator seems to only do one calculation at a time, but I'm not even having luck with that. Maybe it's the way I'm writing the expression Here's the expression I've tried:  

 

 

ExpressionEvaluator settings

 

Destination Attribute: PERCENT_WORKING_INTEREST

 

Arithmetic Expression: @Value(WORKING_INTEREST_ACRES)/@Value(ESTACRES)*100

 

 

If I can get ExpressionEvaluator to work, can you do 2 ExpressionEvaluator transformers in a row?

 

 

HELP ANYONE!!!

 

 

----------

 

 

Here are the 5 fields I will be using. They are all integer fields of some kind and no text.

 

 

ESTACRES (Will be used twice)

 

PERCENT_WORKING_INTEREST

 

WORKING_INTEREST_ACRES

 

UNIT_LEASED_PERCENTAGE

 

SUM_LEASED_ACRES

 

 

Here's the 2 calculations I need to make. (FYI: I've written them out so they would be easier to read and did not input them into any transformer like this)

 

 

Calculation 1:

 

 

PERCENT_WORKING_INTEREST equals WORKING_INTEREST_ACRES divided by ESTACRES multiplied by 100

 

 

Calculation 2:

 

 

UNIT_LEASED_PERCENTAGE equals SUM_LEASED_ACRES divided by ESTACRES multiplied by 100
Hi,

 

 

The calculations are OK (of course, those are pretty basic ones)

 

 

But if u calculate featurebased ( like a row in a table ) the operands must be in the same row, that means they must be linked.

 

Calculating with operands that reside in different rows can be done by reffering to them (somewhat like using cells in Excell)

 

One way of creating referencing would be to use  counters (for indexing the cells) and attributeexploders (accesing cell content).

 

 

If u do grouped calculations, well, you must group. A handy tool for that is Statisticscalulator. Or you could use listbuilder, -summer, -historgrammer etc.

 

 

So PERCENT_WORKING_INTEREST equals WORKING_INTEREST_ACRES divided by ESTACRES multiplied by 100 will only work if  all operands can be accessed (linked to the same object).

 

(btw  remember that 1/2 = 0 and 1/2.0 = 0.5 )

 

 

 

 


Hi,

 

 

an ExpressionEvaluator can only evaluate a single expression, with the result written to a single attribute. But you can of course chain several ExpressionEvaluators one after the other to calculate all your percentages.

 

 

If all your input attributes are integers, you risk that the ExpressionEvaluator will do integer division and thereby truncating the decimals in the result. Fortunately, it is easy to circumvent by telling FME to treat one of the numbers as a floating point number (double), e.g.

 

 

@double(@Value(WORKING_INTEREST_ACRES))/@Value(ESTACRES)*100

 

 

For your expressions, also make sure that the divisor/denominator attribute (ESTACRES) is never zero. You can use a Tester to check, if necessary.

 

 

David
Hi,

 

 

Of course you can use multiple ExpressionEvaluator in a series.

 

Alternatively, you can also use an AttributeCreator to perform 2 or more calculations. You can use the Arithmetic Editor to set expressions, usage of the Editor is same as the ExpressionEvaluator.

 

 

 

Takashi
If they would be a zero division, it would result in a error message. And that is of course easy to prevent.

 

 

I understand from the post that the expressionevaluation does not yield a result at all.

 

And "based on other fields that reside in the same set of data.." kinda indicates that the LonghornedFan is trying to do cross-cell calculations, or otherwise non-linked data.

 

  

 

I think the issue is operands for calculation are not available when the calculation is run.

 

 

 

Also U cannot create dependant calculations in one single creator (one attributecreation using the result of the other).

 

This is not being done here, but just a reminder.

 


I tried the ExpressionEvaluator calculations and it does not like it and fails the job completely. When I remove it, the job runs without the calculations. I'm going to spend some time on the suggestions and I'll get back to you all.

 

 


If you paste error messages which were displayed on the Log when the workspace failed, those would help us to think of solutions.

Reply