Jump to content

Calculate range from negative max and min values


Recommended Posts

I've created a Max Result and a Min Result for a set of Y values.  I'm using a Result Element to calculate the range between the Max and Min Results.  As long as the Max is positive and the Min is negative, or both values are positive, the formula, "getActual("Maximum_Pocket Locations").actual- getActual("Minimum_Pocket Locations").actual" works great, but if both values are negative, i.e. Max -.001 and Min -.0015, etc., then the 2 values add.  How would I prevent this?

If both the maximum and minimum results are negative like in the example, the resulting range should come out as max-min=(-0.001)-(-0.0015)=0.0005. The subtraction sign should be distributing into the negative minimum result, turning it into a positive number in the expression.

On that note, if you want to involve the absolute value function, I would apply it to each result, then apply it to the difference. Something like the following below.

 

 

abs(abs(getActual("Maximum_Pocket Locations").actual)- abs(getActual("Minimum_Pocket Locations").actual))

 

Edited
Re-framing the distribution explanation.
  • Like! 1

Please sign in to view this username.

   I tried that but I when I tested it, I used abs(-0.0010 - 0.0015) which produces 0.0025.  Then I realized I needed to do this  abs(-0.001 -(-0.0015))   DOH 

abs("getActual("Maximum_Pocket Locations").actual- getActual("Minimum_Pocket Locations").actual)

It goes in the Result Element formula field.

Thanks for making think harder.

Please sign in to view this quote.

Ran into this same issue, except in a MS excel table with deviation results from Calypso. I was comparing deviation values on features and needed to calculate to total deviation difference between two features. I ended up asking ChatGPT to produce a formula for me to address the issue you are having, the bot gave me what I needed.

  • Like! 1

Richard, in all of your test values, you inadvertently filled the Max (absolute) value as val1, so when you calculated the abs(val1 - val2), the math always works. In the first example val1 = -10 and val2 = -5.  However, -5 is greater than -10.

I think Mark might be onto something.

Edited

I have to calculate things like this often, I think conditional branch is necessary and safest way, however I would recommend using

Please sign in to view this username.

 's suggestion as well , creating theoretical points, and output the distance of this line. 

here is 2 diameters and we are wanting the distance, one diameter is in the negative Y axis and one in the positive Y axis. The first test, we need to check if Circle1 is the diameter that we need to convert to a positive value. The next test is checking if Circle2 is the diameter we need to change to a positive value.
 

Var1 = getActual("Circle1").y

Var2 = getActual("Circle2").y

 

if Var1<0.000 then

Var3 = abs(Var1)

Dist = Var3+ Var2

endif

 

if Var2<0.000 then

Var4 = abs(Var2)

Dist = Var1+ Var4

endif

 

In the Result Element add Dist to the formula

  • Awesome! 1
×
×
  • Create New...