Select to view content in your preferred language

If Statement Calculation with Integer Questions

1378
5
Jump to solution
10-20-2020 12:36 PM
DanBihari
Regular Contributor

I am building a soil mapping survey and am having a problem with one of my calculations.  I have repeat questions related to the soil's profile.  Each repeat represents a soil horizon.  Some of the properties that need to be captured is the Upper and Lower depths.  What I am attempting to do is:

if HORIZON_NO = 1

   UPPER = 0

else

   UPPER = LOWER_MAX

LOWER_MAX is the max of the LOWER measurement recorded in the repeats.  Essentially the first horizon will have an UPPER measure (depth) of 0.  The second repeat or horizons will now automatically populate the upper to equal the previous lower.  The code that I used is:

if (${HORIZON_NO}=1, 0, ${LOWER_MAX})

What ends up happening is that first repeat does not get a 0 and when I capture a second repeat it actually concatenates the 1 and 0 from my if statement.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

I do this as well for my Soil Pits.  I cant tell who you work for it may be similar then I could share my forms.

But the trick I got was to use once hidden field and a once so that it stays put and does not recalc on me.  I also add the 0 to the max.  I forget my process since it was a few years ago but it works.

Hope that helps

View solution in original post

0 Kudos
5 Replies
ZacharySutherby
Esri Regular Contributor

Hello Dan Bihari‌, 

Is the second repeat or the HORIZON_REPEAT nested within a repeat that LOWER_MAX is contained in? Additionally is there a repeat count set for either the outer or nested repeat? 

If so we have a few issues with calculations in nested repeats. 

If possible would I be able to obtain a copy of your XLSForm for testing on our end to confirm if this is the same behavior as our issue? 

Thank you, 

Zach

Thank you,
Zach
0 Kudos
DanBihari
Regular Contributor

Hey Zach,

For some reason my GeoNet is all messed up and I am having trouble using it on a consistant basis. I assume that it’s related to the GeoNet migration. I hope you don’t mind that I respond to you directly.

So what I am trying to do is once a soil pit is dug you have multiple soil horizons. Each repeat represents a new soil horizon. With each soil horizon you have an upper measurement, which start at 0, and a lower measurement which represent the depth. What I’m attempting to do is as the second repeat is started, the lower measurement from the first repeat is automatically enter in for the upper of the second repeat.

First Repeat

Upper – 0

Lower – 25

Second Repeat

Upper – 25

Lower – 45

Third Repeat

Upper – 45

Lower – 60

Etc…

This work starts at row 111 and my LOWER_MAX calc is on row 87.

Thank you very much for your help Zach.

Cheers!

~Dan

Dan Bihari (he/him)

Senior Geographic Information Specialist

Resource Information Business Services Unit

0 Kudos
DougBrowning
MVP Esteemed Contributor

I do this as well for my Soil Pits.  I cant tell who you work for it may be similar then I could share my forms.

But the trick I got was to use once hidden field and a once so that it stays put and does not recalc on me.  I also add the 0 to the max.  I forget my process since it was a few years ago but it works.

Hope that helps

0 Kudos
DanBihari
Regular Contributor

Doug…

YOU ARE A GENIUS!

Thank you SOOO much. That worked perfectly.

~Dan

Dan Bihari (he/him)

Senior Geographic Information Specialist

Resource Information Business Services Unit

DougBrowning
MVP Esteemed Contributor

Cool.  Please mark the post as correct.  thanks

0 Kudos