Agreement in 4 fields

This topic is 2809 days old. Please don't post here. Open a new topic instead.

Recommended Posts

• Newbies

I have 4 fields called sibling 1, 2, 3, 4 that contains different languages. I want to create a 5th field to evaluate the 4 language fields and to say "Yes" or "True" they are all the same language, or to say "No" "False" they are not all the same language.

An "IF" calculation works for comparing 2 fields but I can't get it to work for 4 fields. Any ideas?

Share on other sites

This could be done by =

```Let (
allLangs = List ( Lang1 ; Lang2 ; Lang3 ; Lang4 )
;
ValueCount ( FilterValues ( allLangs ; Lang1 ) ) = 4
)```

This will return 1 (True) if all the LangX fields contain the same value, 0 (False) otherwise. If all four fields are empty, the result will be False, too.

That said, having numbered ("sibling") fields is usually a symptom of inadequate structure. Why aren't you using related records instead?

• 1
Share on other sites

Hi Julie, welcome to FMForums!  :-)

As an aside for future reference, an If() function only allows two possible values - read up in FM Help about it.  If you want similar calculation which allows more than two values, read up on Case() function.

Share on other sites

An "IF" calculation works for comparing 2 fields but I can't get it to work for 4 fields.

an If() function only allows two possible values

I believe there are only two possible values here as the result - either true or false. The problem is not with the If() function itself. It's the = operator that will only compare two values at a time. But you could still use the If() function and test for =

`Lang1 = Lang2 and Lang2 = Lang3 and Lang3 = Lang4`
Share on other sites

This topic is 2809 days old. Please don't post here. Open a new topic instead.

Create an account

Register a new account