Jump to content

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

Recommended Posts

Posted

I have 6 different fields that ea. will hold a number between 1 and 10. Is there a type of calc that can be used that would look at the six fields, and if any 2 or 3 or 4 fileds have the same matching number, the calc returns a value of "True", otherwise "False."

LR

Posted

True if 2, 3, or 4 match, but false if 5, 6, or none match?

What about a full house... or a pair and 4 of a kind? Is that true?

In any case, the answer to the question is "sure, there is an expression".

The question is "how short can that expression be?"

Posted

LOL. I guess it can all be done with a lot of "if" statements. I mean a lot because I need to generate a true if any of the six fields happen to contain the same number, or better put, if any one number gets used more than once.

LR

Posted

Cross-record calculation ?

If not...why not

c_Group = field 1 &"-"& field2 &"-"&field3&"-"&field4&"-"&field5"-"&field6

c_checkValid = Case(Patterncount(c_Group, field1) > 1 or Patterncount(c_Group,field2) >1 or Patterncount(Patterncount; field3) >1 or Patterncount(c_Group, field4) >1 or Patterncount(c_Group, field5) >1 or Patterncount(c_Group, field6) >1,1,0)

Posted

There's a slight typo there the 'field3' check.

Since there's only one long condition to check, you may as well use an If() function rather than a Case() function, but that makes little difference.

You could also simplify it slightly by removing the 'field6' check ... if you haven't found any matches up to 'field5', then you can't possibly find one for 'field6', so why bother checking. smile.gif

Posted

Yep Harry,

So what about simplifying it a little more

Patterncount(c_Group, field1) > 1 or Patterncount(c_Group,field2) >1 or Patterncount(Patterncount; field3) >1 or Patterncount(c_Group, field4) >1 or Patterncount(c_Group, field5) >1

laugh.gif

Boolean 1,0 no need for If either...

Posted

You could do that and it'd work perfectly - it just depends if the original person wants an 'internal' "True" / "False" value for further calculations / scripts or if they want to display "True" / "False" text values on-screen. smile.gif

Edit: On second thoughts, this method won't work if the values can include "10", since the '10' would also get counted as part of the PatternCount() for '1', but isn't a true match for '1'. ooo.gif

The esiest way around this would probably be to have a second set of value fields that convert the originals into hexidecimal values and then use these fields in the c_Group and c_CheckValid calculations.

ie. field 1_hex = If(field 1 = "10", "A", field1)

etc. for all six value fields.

That way "A" won't get included in the PatternCount() for '1'. smile.gif

Posted

If you include the separator at the beginning and ending of the c_Group field as well, then you need not worry about 1 being counted in 10. Just use PatternCount(c_Group, "-" & field1 & "-" ) > 1, etc.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.