Conditional default

653
1
02-07-2018 04:37 PM
BonnieWeller1
New Contributor III

I understand that defaults are set when you open the form and therefore you cannot base the default on the answer to a previous question; however, I am wondering how to approach the following scenario:

My form has three parts, the data at the beginning of the road survey, the sightings along the route, and the data at the end of the road survey.  I open the repeat section (sightings along the route) if a sighting has occurred, otherwise skip that section and proceed with the ending section. I want the default number of birds sighted at a given coordinate set to 1 if the question about whether a sighting has occurred along the route is "Yes", otherwise the default is 0 - since it seems there is always one record uploaded in the repeat section, even if no data was entered (sighting occurred along the route is "No") I would like to have this set to zero if NO information was to added to this "record". Putting this "If equation" in the calculation field did not work as the number of sightings at that location could equal more than 1 (just not very often) and the calculation would always set number of birds sighted at that location back to 1.  Thus far I do not see a way to set things up like the way I would like so I am simply making the default set to one and forgetting the conditional statement. Am I correct in assuming this can't be set up to work the way I want?

Tags (1)
0 Kudos
1 Reply
NickDierks
New Contributor III

It sounds like you have a yes/no question about bird sightings in your repeat, and then a total number of birds sighted outside the repeat? If that's the case, try adding a hidden/null field inside the repeat with the following calculation: if(selected(${YESNO}, 'yes'), '1', '')

Then, you can set your total sightings question with a calculation of if(count(${HIDDENFIELD})>0, '1', '0'). This will give you your default of 1 if there are any 'Yes' answers, and 0 otherwise.

OR

If your goal was to manually change the 1 to a higher number if there were multiple sightings: Set your total sightings question with a calculation of count(${HIDDENFIELD}). This will count all of times you checked 'Yes', while all 'No' answers and skips will stay out of your total. So, a skipped section will equal 0, or a survey with three 'Yes' and four 'No' answers will equal 3.

Again, I'm not sure I have your workflow quite right, but hopefully this is a start.

0 Kudos