Hello!
I created a Survey123 xlsform. for those who may be unaware, using and XLSform based survey in the Survey123 app acts much differently than opening the same survey in a browser.
within the app i had originally written a calculation:
if(${practice}="Cover Crop (340)(acres)",round(pulldata('covercrops','phosphorus','county',${county})${costshareac},2),if(${practice}="Conservation Cover (327)(acres)",round(pulldata('grassedpractices','phosphorus','county',${county})${costshareac},2),if(${practice}="Critical Area Planting (342) (acres)",round(pulldata('grassedpractices','phosphorus','county',${county})${costshareac},2),if(${practice}="Filter Strip (393)(acres)",round(pulldata('grassedpractices','phosphorus','county',${county})${costshareac},2),""))))
This worked great in the app - I am referencing some CSVs (grassedpractices.csv, covercrops.csv) in this formula. You'll notice there are multiple if statements here.
To make this work well on a browser, I had to move the pulldata into new calculation rows and then call them. Below is my workaround:
This works fine (s_1):
if(${practice}="Cover Crop (340)(acres)",${s_cov},0)
(s_cov):
pulldata('covercrops','sediment','county',${county})*${costshareac}
THIS is where things get weird - If I try to apply this to multiple "if" statements then we run into some problems.
Example (s_2):
if(${practice}="Cover Crop (340)(acres)",${s_gp},0),if(${practice}="Conservation Cover (327)(acres)",${s_gp},0),if(${practice}="Critical Area Planting (342) (acres)",${s_gp},0),if(${practice}="Filter Strip (393)(acres)",${s_gp},0)
when I try to string them together like I did before I recieve an XFormParseException error indicating a Bad node.
(s_gp) referenced in above formula:
pulldata('grassedpractices','sediment','county',${county})*${costshareac}
Error:
any obvious issues?
2. What app or server are you using and on what device and operating system? Include version numbers.
Survey123 - Web Browser (tested in Chrome, Firefox, and Edge).
Windows 10, excel 2013, survey123 connect for ArcGIS 3.5
So far I've tried
-nesting the if statements, but it doesn't accomplish what I need.
-moving the pulldata rows above the if calculations
-creating a new row for each "if" (this works, but seems untidy and silly)
-changing the "type" to "hidden" and "decimal" rather than "calculate"
-putting many things in and out of parenthesis
Additionally:
I'm not attaching the form itself for privacy sake (certain choices), but if you really must have it I can make version that is gleaned of this information.
Thank you!
Trevor
>if(${practice}=${grassedpractice},${s_gp},"")
I created a new choice and referenced it rather than putting a "quoted text" in as a cursor.
Thanks
Hi Trevor,
It would be helpful if you could share the XLSFile to diagnose this. Also, just to check - the statement in you XLSFile has the appropriate number of closing parenthesis? It seems a few are missing form your copy/paste.
Hi James -
Turns out all I needed was an appropriate nested-if statement.
I was able to find some help on the ODK forum - and I'm sharing here in case someone else runs into a similar problem.
Thank you!