Select to view content in your preferred language

'if' Statement Arguments Error

535
2
02-06-2024 07:16 PM
Labels (1)
HanggarPrasetio1
Emerging Contributor

Hi,  I have a conditional statement calculation in my survey in that is returning an error: 

"XPath evaluation: cannot handle function 'if' requires 3 arguments, Only 2 provided." 

As you can see , so I am stumped.  Your input is much appreciated.

 

if(selected(${JenisPelanggaran},'1'),'Alat Tangkap', if(selected(${JenisPelanggaran},'2'),'Biota Dilindungi', if(selected(${JenisPelanggaran},'3'),'Destruktif/ Merusak', if(selected(${JenisPelanggaran},'4'),'Habitat Penting', if(selected(${JenisPelanggaran},'5'),'IUU Fishing', if(selected(${JenisPelanggaran},'6'),'Jasa Lingkungan (TLPJL)', if(selected(${JenisPelanggaran},'7'),'Pengrusakan Terumbu Karang', if(selected(${JenisPelanggaran},'8'),'Pengrusakan Padang Lamun', if(selected(${JenisPelanggaran},'9'),'Pengrusakan Mangrove', if(selected(${JenisPelanggaran},'10'),'SOP Pemanfaatan', if(selected(${JenisPelanggaran},'11'),'Zonasi')))))))))))

0 Kudos
2 Replies
ChrisUnderwood
Esri Contributor

Hello @HanggarPrasetio1  , is your last expression missing a value for when the condition is False ?

Something like :

if(selected(${JenisPelanggaran},'11'),'Zonasi','None of the above'

This post has an example 

https://community.esri.com/t5/arcgis-survey123-questions/survey123-calculation-multiple-if-parameter...

if(condition, value if true,
if(condition, value if true,
if(condition, value if true,
if(condition, value if true,
if(condition, value if true, value if false)))))

abureaux
MVP Frequent Contributor

Helpful tip for S123. While the formulas in the XLSX sheet are NOT Excel compatible, Excel will still give you the "helper" features if you add in "=" in front of the formula.

To do this and check your formula:

  1. Write a S123 formula and press enter (i.e., just exit the cell)
  2. Click back into the cell, and add "=" to the start
    abureaux_0-1707340910633.png
  3. You will now see color-coded brackets. Also, if you use the arrow keys to scroll over brackets, the matching brackets will be highlighted. And finally, you also get to take advantage of Excel's logic guide:
    abureaux_2-1707341216577.png
    1. Without going into too many specifics, you can use this mode to check for balanced brackets and proper formula set-up. E.g., You should only see a single "white" bracket at the end of any nested IF statement. If you see more than one, you have unbalanced brackets
      abureaux_1-1707341072997.png
  4. Be sure to delete the "=" before saving the XLSX or you will get an error.
0 Kudos