Validating based on multiple form values

Hi. I'm trying to validate a form based on multiple values entered. 

If field Number (number) is higher than, say, 100, and field Origin (enum) is Blue, and field Destination (enum) is Green, then Valid

There are a few permutations of the above that are valid and others that would make the form invalid.

I tried creating a hidden field called Validation (Yes/No) to check the input of those 3 fields, but it doesn't seem to work.

Any help appreciated.

Solved Solved
0 2 141
1 ACCEPTED SOLUTION

Since you are indicating that you have multiple sets of conditions you need to check I would suggest you assign the 'Valid if' condition to a singular field, probably the last one that needs to be filed out for the 3 fields. Furthermore you can use the IFS() formula for this as follows:

IFS(
AND([Number] > 100, [Origin] = "Blue", [Destination] = "Green"), TRUE,
AND([Number] <= 100, [Number] > 50, [Origin] = "Yellow", [Destination] = "Red"), TRUE,
TRUE, FALSE
)

The way to read this is if condition1=true than validation=true(pass), else move to condition2=true than validation=true(pass), else move to condition3 which is set as true, but validation=false(no pass). So you can expand this to unlimited conditions, however the last condition and result needs to essentially address how the validation needs to be handled if none of the previous conditions were true. That is why the last statement condition3 is a TRUE, FALSE statement because if none of the previous conditions evaluated to true, then the validation needs to fail. You should probably also include a customized valid if message that would indicate what the valid choices are, or do conditional dropdowns or present different 'suggested values' based on selections in prior fields.

View solution in original post

2 REPLIES 2

What is your current expression?

I would imagine it should look something like the following:

AND(
[Number]>100,
[Origin]='Blue',
[Destination]='Green'
)

Since you are indicating that you have multiple sets of conditions you need to check I would suggest you assign the 'Valid if' condition to a singular field, probably the last one that needs to be filed out for the 3 fields. Furthermore you can use the IFS() formula for this as follows:

IFS(
AND([Number] > 100, [Origin] = "Blue", [Destination] = "Green"), TRUE,
AND([Number] <= 100, [Number] > 50, [Origin] = "Yellow", [Destination] = "Red"), TRUE,
TRUE, FALSE
)

The way to read this is if condition1=true than validation=true(pass), else move to condition2=true than validation=true(pass), else move to condition3 which is set as true, but validation=false(no pass). So you can expand this to unlimited conditions, however the last condition and result needs to essentially address how the validation needs to be handled if none of the previous conditions were true. That is why the last statement condition3 is a TRUE, FALSE statement because if none of the previous conditions evaluated to true, then the validation needs to fail. You should probably also include a customized valid if message that would indicate what the valid choices are, or do conditional dropdowns or present different 'suggested values' based on selections in prior fields.

Top Labels in this Space