Count unique instances of a value within a repeat using SUM

1028
1
Jump to solution
11-08-2018 03:35 PM
Yuhash
by
Occasional Contributor

I am wanting to count the unique instances of a value within a repeat. Others have had the same issues resolved by explicitly casting the values as integers but this isn't resolving my issue.

Survey123 Addition Calculation Treating Numericals as Text Fields  

https://community.esri.com/thread/203632-sum-aggregate-function-appends-values-doesnt-add-them 

I have a calculate field based on a conditional IF statement such that if the condition is met a value is set. Outside of the repeat I have a sum of the conditional field. But instead of summing the integers, the output is a concatenation of text despite trying to cast values as integers and binding as an esriFieldTypeInteger.

if(condition),1,0)

sum(FIELD)

Attached is this example.

e.g.Instead of the value 2, I have 10100

typenamelabelcalculationbind::esri:fieldType
begin repeatRatings
select_one ratingRatingRating
calculateCount_1_Starif(${Rating}=1,int(1),int(0))esriFieldTypeInteger
integernoteNote${Count_1_Star}
end repeat 
integerInteger_CountCountsum(${Count_1_Star})esriFieldTypeInteger

0 Kudos
1 Solution

Accepted Solutions
Yuhash
by
Occasional Contributor

I changed the 'type' of field to an 'integer' from 'calculate' and it works now. I will note that the 'esriFieldTypeInteger' designation has no impact, rather, it is the 'type' field that is significant as explained in Esri custom columns—Survey123 for ArcGIS | ArcGIS  .

Alternately, I can keep the 'type' field as 'calculate' and specify the data type in the 'bind::type' field.

typenamelabelcalculationbind::type
begin repeatRatings   
select_one ratingRatingRating
calculateCount_1_Star1_starif(${Rating}=1,int(1),int(0))int
end repeat     
integerInteger_CountCountsum(${Count_1_Star})int

View solution in original post

1 Reply
Yuhash
by
Occasional Contributor

I changed the 'type' of field to an 'integer' from 'calculate' and it works now. I will note that the 'esriFieldTypeInteger' designation has no impact, rather, it is the 'type' field that is significant as explained in Esri custom columns—Survey123 for ArcGIS | ArcGIS  .

Alternately, I can keep the 'type' field as 'calculate' and specify the data type in the 'bind::type' field.

typenamelabelcalculationbind::type
begin repeatRatings   
select_one ratingRatingRating
calculateCount_1_Star1_starif(${Rating}=1,int(1),int(0))int
end repeat     
integerInteger_CountCountsum(${Count_1_Star})int