Select to view content in your preferred language

Survey123 If Then but no Else

4121
15
09-23-2019 01:15 PM
JulienCHARBONNAUD
Regular Contributor

Hello

In my Survey123 form, I want to use the If expression in the Calculation column. By default, in the formula if (condition, a, b), you need a and b, in my case I will not want any action if the condition is not fulfilled.

Example if (format-date ($ {DateMeasure}, '% W') = 27, $ {Biom}, NO ACTION WISHES)

because it means that my cell is already informed and I do not want to overwrite its content

If anyone has a trick

Thank you very much

(Google translation)

15 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Julien,

Unfortunately, there is not a method to preserve the existing data as part of an if() calculation; the else part is required.

JulienCHARBONNAUD
Regular Contributor

Hi James

Thank you for this quick response

Pity

Maybe you have another idea?

Explanation: when typing with a repeat function, I test the date and I store a value in the main database with a variable that has the number of week (Week 37 for example) when re-entering the value can be assigned to week 40 for example but it does not do that the value of week 37 disappear.

Thank you 

Julien

0 Kudos
DougBrowning
MVP Esteemed Contributor

You could try a second hidden var.  Use once() if you need to.  Then your If could say new week or load from hidden field.

0 Kudos
JulienCHARBONNAUD
Regular Contributor

Hi Doug

I have a little research on this side, but I did not understand how works once() and I did not find much help on the subject
If you want to give me a hand it is with pleasure
thank a lot

Julien

0 Kudos
DougBrowning
MVP Esteemed Contributor

See this page Formulas—Survey123 for ArcGIS | ArcGIS 

If a question already has a value, returns the existing value. Useful when using random() or uuid() in a repeated question to ensure the value doesn't change when you browse through the repeat records in the form.

If fieldB is once(fieldA) then when they change fieldA it will retain the value in FieldB.

0 Kudos
JulienCHARBONNAUD
Regular Contributor
Hi Doug Thanks for your support ! I can not follow you
In fact, I enter: -a date -a value with the date I calculate the number of week I have several variables Week27 Week28 .... and I copy the value in the good week.  but as I use a loop when I put a new date and a new value corresponding to a new week. The test if erases the value of the other weeks already filled.
So it would be necessary to be able to test if the variable is already filled doing nothing but I block
if you have a great idea

Bye
Julien
0 Kudos
DougBrowning
MVP Esteemed Contributor

I am sorry but I do not understand.  Post your form if you can.

0 Kudos
JulienCHARBONNAUD
Regular Contributor

here is

0 Kudos
DougBrowning
MVP Esteemed Contributor

You need to move all those Sem fields into the repeat as well.  You are asking the value of DateMeasure outside the repeat.  When you do this it only will see the last one entered.  You want to calc the Sem for each repeat so it needs to be inside.

0 Kudos