Help with Valid If required

Hi folks,

I need a little help with a form I’ve created. One of the questions is of type enumlist however I don’t want respondents to be able to select all of the options.

The question I’m asking is ‘Have you made any of the following via the app:’

The options are;
Connections with a colleague
Buddy with a colleague
None

So basically if the respondent selects ‘None’ then they shouldn’t be able to select either of the other options and vice versa. I’ve read that this is achievable using the ‘Valid If’ field but I just can’t get it to work.

Any help with this would be much appreciated. Thanks!

For solving your troubles, give us your data structure and “valid if” expr you use

1 Like

U have to use the IFS() and [_THIS] to create the conditions for the enum values
eg:
IFS(
[_this] = [colunm1], ISNOTBLANK([colunmX]),
[_this] = [colunm2], ISNOTBLANK([colunmy]),
[_this] = [colunm3], ISNOTBLANK([colunmw])
)

Try this:

IF(
  NOT(IN("None", [_THIS])),
  LIST(
    "Connections with a colleague",
    "Buddy with a colleague",
    "None"
  ),
  LIST("None")
)
1 Like

Thanks Steve. I tried this however I’m getting the following error

‘Parameter 2 of function IN is of the wrong type’

It’s not liking [_THIS] for some reason??

I also gave this expression a go which was accepted but it still allowed me to select ‘None’ and any of the other options, so it’s still not doing what I want it to.

IF(
(IN([_THIS],List(“None”))),
LIST(
“None”
),
LIST(
“Connections with a colleague”,
“Buddy with a colleague”,
“Connections and Buddy with a colleague”,
“None”)
)

As a workaround I’ve changed the field type to Enum rather than Enumlist and have added the additional option of “Connections and Buddy with a colleague”. This way the user only needs to select one option so no need for a Vaild If.

It still would be great to know if this if possible and how to achieve it. Thanks for all input though.

1 Like

Try

IF(
  NOT(
    IN(
      "None", 
      SPLIT([_THIS], " , ")
    )
  ),
  LIST(
    "Connections with a colleague",
    "Buddy with a colleague",
    "None"
  ),
  LIST("None")
)
2 Likes

Thanks @SkrOYC it seems to accept this expression in the Valid If field, however it still isn’t working as I wanted. It’s allowing me to make selections of “None” with any of the other options. Also the Invalid Value Error message doesn’t display if I select “None” along with another option?!

Some interesting behaviour though. If I select only “None” and move on to the next question then my response of “None” is now shown as a single button. If I choose any of the other answers then they are displayed as a comma separated list.

I think the following simple expression can work for ‘Valid If’-

IF((FIND(“None”,[_THIS]))>1,FALSE,TRUE)

Actually it is working so far.

Actually, I don’t use Valid_If at all for lists. I prefer Suggested Values

Thank you @shahappsheet! This seems to work for me as well :smiley:

A really simple and elegant solution to the problem.

2 Likes

I know very little about the Suggested Values. I have seen only that it give a list like dropdowon. Thanks Oscar to open my eyes towards this. Now I will explore it. Actually, I am very very new in AppSheet. Thanks again.

1 Like