Calculation only works when both choices selected

510
2
Jump to solution
02-15-2022 01:15 PM
kawakawa4
New Contributor III

I have a repeat with a select_one question inside it.

kawakawa_0-1644958974074.png

The select_one opens either an integer field or a simple calculation:

kawakawa_1-1644959038734.pngor:kawakawa_2-1644959084467.png

I want the Total eggs in natural habitat field to be the sum of Count of all eggs within quadrat and Total eggs calculation. But it doesn't populate if every choice from the select one is the same, only if a mixture of choices is made. Is there a way to make the calculation work if all choices are the same?

I have attached the excel form if the image is not clear.

kawakawa_5-1644959547113.png

Many thanks

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
Jim-Moore
Esri Regular Contributor

Hi @kawakawa4 

The total eggs calculation is not working when only one of the choices is selected for all repeats because one half of the sum is null (i.e. if one of the eggcount questions remains not relevant across all repeats, its value is null).

One way around this would be to use the coalesce() function in the total calculation, which will overcome any null values (replacing null with zero). Something like:

coalesce(sum(${Egg_Natural_Less200_EggCount}), 0) + coalesce(sum(${Egg_Natural_More200_EC_Total}), 0)

Hope this helps. Best, Jim

View solution in original post

2 Replies
Jim-Moore
Esri Regular Contributor

Hi @kawakawa4 

The total eggs calculation is not working when only one of the choices is selected for all repeats because one half of the sum is null (i.e. if one of the eggcount questions remains not relevant across all repeats, its value is null).

One way around this would be to use the coalesce() function in the total calculation, which will overcome any null values (replacing null with zero). Something like:

coalesce(sum(${Egg_Natural_Less200_EggCount}), 0) + coalesce(sum(${Egg_Natural_More200_EC_Total}), 0)

Hope this helps. Best, Jim

kawakawa4
New Contributor III

Perfect solution, many thanks Jim!