Calculation help

265
3
Jump to solution
05-27-2020 12:02 PM
DanielSenner1
New Contributor

Good Afternoon I am building a Water Quality field data sheet and I am hoping someone can help me out.  Our water Quality crews go out and take up to 4 but not always 4 could be 3,2,or 1 measurements.  After taking the measurements they perform a calculation to determine if the measurements are within 10% of each other.  The calculation I have come up with is below.  I am wondering how if there is a way to make it so the value returned is always positive.  For example is the first measurement is 5.7 and the second is 6.2 the value returned is -8.403361344537814. I would like it to be returned as a positive number.  I am also wondering if there is a way to control the number of decimal places that are returned.

(${secchi_depth} - ${secchi_depth_a}) div ((${secchi_depth} + ${secchi_depth_a}) div 2) *100

Thanks

Dan Senner

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KatherineZybko
New Contributor

There doesn't seem to be support for an absolute value function, so I've gotten around that by taking the second power and then the square-root so that it is always positive. (sqrt(pow((YOUR_FORMULA),2))

To control the decimal places use round(sqrt(pow((YOUR_FORMULA),2)),3) -in this case it's rounding it to 3 decimal places.

This page should be a helpful reference:

Formulas—Survey123 for ArcGIS | Documentation 

View solution in original post

3 Replies
KatherineZybko
New Contributor

There doesn't seem to be support for an absolute value function, so I've gotten around that by taking the second power and then the square-root so that it is always positive. (sqrt(pow((YOUR_FORMULA),2))

To control the decimal places use round(sqrt(pow((YOUR_FORMULA),2)),3) -in this case it's rounding it to 3 decimal places.

This page should be a helpful reference:

Formulas—Survey123 for ArcGIS | Documentation 

DanielSenner1
New Contributor

Hi Katherine, thank you for the above recommendation.  When I tried to use this example round(sqrt(pow((YOUR_FORMULA),2)),3) I keep getting unbalanced brackets and I cannot seem to figure out what I am doing wrong.  I put my formula in from above where you say to put it but no luck.  Any additional help or guidance with this would be appreciated. 

Thanks

Dan

0 Kudos
DougBrowning
MVP Notable Contributor

I did mine with an if instead.

from a repeat of shots

if(sum(${ElevationChange1})>0, sum(${ElevationChange1}), sum(${ElevationChange1}) * -1)

then compare across passes

100* ((${TotalElevationChangePass1} - ${TotalElevationChangePass2}) div ${TotalElevationChangePass1})

Again the negative in a hidden field just to make it easier to read

if(${SumCalc} > 0, round(${SumCalc},1), round(${SumCalc}*-1,1))

Then I have a note 

Pass 3 is needed  with a relevant of  ${SumCompare} > 10 " Pass 1 and Pass 2 are not within 10%"

Seems to be working so far.

Hope that helps.

0 Kudos