### Post

3 followers Follow

# If else statement - using value from one field if used, else use another fields value

Hi, I am trying to figure out how to solve an issue regarding some calculations. Basically I need a calculation to take the value from one field, if that field is used, or else i need the value from another field.

So, If Field1 is filled out with Value1, I need Value1 to be the value that the calculation is using, otherwise if Value1 is equal to 0 or nothing, the calculation has to take Value2 from Field2, and use that amount in the rest of the calculation.
Is that possible?

Jacob Heydenreich Jensen

Hi Jacob,

you can do this:

`var field1 = @field1;var field2 = @field2;var numberToUse = field1 == null || field1 == 0 ? field2 : field1;`

Then use the variable in your calculation, like
10 + numberToUse / 5

Rainer

Rainer Grabowski 0 votes

Viva Jacob.

Tente:

if (@Campo1 == null) {
@Campo 2;
} else {
@Campo1;
}

Abraço

Claudio Sambuta 0 votes

Thank you very much guys :)
It worked!

Jacob Heydenreich Jensen 0 votes