July 18, 200322 yr 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
July 18, 200322 yr 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?"
July 18, 200322 yr Author 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
July 18, 200322 yr 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)
July 19, 200322 yr 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.
July 19, 200322 yr 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 Boolean 1,0 no need for If either...
July 19, 200322 yr 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. 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'. 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'.
July 19, 200322 yr 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.
Create an account or sign in to comment