Hello All,
I receive daily data from real-time survey 123 form. I am trying to calculate a (daily) sum of the rows within a field ('total_pateints') based on categories within another field ('region'). The output of the sum goes to a third field ('daily_overall_pateints'). My hosted feature layer has following fields:
1. region (categorical field with values = hospitalA, hospitalB, hospitalC, hospitalD and hospitalE)
2. total_patients (numerical field)
3. submission_date (date of survey 123 form submission; survey is summitted daily)
4. daily_overall_pateints (numerical filed which is to be calculated via the coding shown below)
if($feature.region == "hospitalA")
{
var T1=$feature["total_patients"];
var S1=$feature["submission_date"];
}
if($feature.region == "hospitalB")
{
var T2=$feature["total_patients"];
var S2=$feature["submission_date"];
}
if($feature.region == "hospitalC")
{
var T3=$feature["total_patients"];
var S3=$feature["submission_date"];
}
if($feature.region == "hospitalD")
{
var T4=$feature["total_patients"];
var S4=$feature["submission_date"];
}
if($feature.region == "hospitalE")
{
var T5=$feature["total_patients"];
var S5=$feature["submission_date"];
}
daily_overall_Patients=0;
if(S1==S2==S3==S4==S5) {
daily_overall_Patients=T1+T2+T3+T4+T5;
return daily_overall_Patients;
}
While testing this code, I received the following error. The line 38 in the error message below has been written in green color in the code above. I tried to resolve the error but unfortunately I could not. Can anyone please assist me with the solution to this error ? Thanks in advance :).
Does not seem to like this:
if(S1==S2==S3==S4==S5)
Probably a better way, but testing shows that this works:
if(S1 == S2 && S2 == S3 && S3 == S4 && S4 == S5)
or this:
if(S1 == S2 && S1 == S3 && S1 == S4 && S1 == S5)
R_
Hello @RhettZufelt ,
I appreciate you taking time to look into this issue but unfortunately I receive the same error with the solution you provided. Not sure what identifier is not being recognized by Arcade and why.
Suspect because you don't declare any of the S# or T# variables until a condition is met.
Then, you are trying to compare all of them and/or add them together. Suspect if you declare them ahead of time, error would go away.
var S1 = ''
var S2 = ''
var S3 = ''
var S4 = ''
var S5 = ''
var T1 = 0
var T2 = 0
var T3 = 0
var T4 = 0
var T5 = 0
Rest of code here......
R_