what is the best way to check 60 different conditions in my if statement?

  • Thread starter mls via AccessMonster.com
  • Start date
M

mls via AccessMonster.com

Hi,

I have 20 different test and have to check for all the permutations and
combinations for each of these test( test1=yes and test2=no and test3=yes etc)
and then finally create a result field.
So what is the best way to do this?

Thanks
 
J

Jeff Boyce

20 objects, taken how many at a time?

"...create a result field ..." ?from what? ?consisting of what?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
M

mls via AccessMonster.com

I have 20 different tests and each time I have to check a minimum of 2
combinations upto a maximum of 12 different combination to create a results.

simple Ex:
If test1_result=yes and test2_result=no then result="A";
else if test1_result=yes and test2_result=yes then result="Mix A and B";
above example is just checking 2 conditions(tests). I am planning to check
atleast 12 conditions in one if statement and expecting to have 50 such if
statements.

Jeff said:
20 objects, taken how many at a time?

"...create a result field ..." ?from what? ?consisting of what?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP
[quoted text clipped - 5 lines]
 
J

Jeff Boyce

You might want to revisit the math in your combinatorics.

If you are taking 20 objects (tests) 2 at a time, you have 190 possible
combinations.

Then if you are taking them three at a time, you have approx. 63
possibilities. Taken four at a time, ...

So I'm guessing there are a very specific set of your "50 such"
combinations.

Why not use a table to hold the valid combinations, rather than try to write
a fairly complex (and likely, "Too complex" from Access' viewpoint)
expression?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

mls via AccessMonster.com said:
I have 20 different tests and each time I have to check a minimum of 2
combinations upto a maximum of 12 different combination to create a
results.

simple Ex:
If test1_result=yes and test2_result=no then result="A";
else if test1_result=yes and test2_result=yes then result="Mix A and B";
above example is just checking 2 conditions(tests). I am planning to check
atleast 12 conditions in one if statement and expecting to have 50 such if
statements.

Jeff said:
20 objects, taken how many at a time?

"...create a result field ..." ?from what? ?consisting of what?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP
[quoted text clipped - 5 lines]
 
J

JimS

If you really feel you have to do this the way you describe, you probably
want to create a matrix of binary values (0 is true, 1 is false). Then you
can loop through the matrix and use boolean logic to develop the result.
--
Jim


Jeff Boyce said:
You might want to revisit the math in your combinatorics.

If you are taking 20 objects (tests) 2 at a time, you have 190 possible
combinations.

Then if you are taking them three at a time, you have approx. 63
possibilities. Taken four at a time, ...

So I'm guessing there are a very specific set of your "50 such"
combinations.

Why not use a table to hold the valid combinations, rather than try to write
a fairly complex (and likely, "Too complex" from Access' viewpoint)
expression?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

mls via AccessMonster.com said:
I have 20 different tests and each time I have to check a minimum of 2
combinations upto a maximum of 12 different combination to create a
results.

simple Ex:
If test1_result=yes and test2_result=no then result="A";
else if test1_result=yes and test2_result=yes then result="Mix A and B";
above example is just checking 2 conditions(tests). I am planning to check
atleast 12 conditions in one if statement and expecting to have 50 such if
statements.

Jeff said:
20 objects, taken how many at a time?

"...create a result field ..." ?from what? ?consisting of what?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP

Hi,

[quoted text clipped - 5 lines]

Thanks


.
 
M

mls via AccessMonster.com

Sorry if I confused you. I start my code by checking 2 conditions inistially,
but later it will go upto 12 different conditional checks. It might be
approximately 50 such combination.
I like the idea of storing valid combinations in table, can you explain me
more. how can I use this?

Jeff said:
You might want to revisit the math in your combinatorics.

If you are taking 20 objects (tests) 2 at a time, you have 190 possible
combinations.

Then if you are taking them three at a time, you have approx. 63
possibilities. Taken four at a time, ...

So I'm guessing there are a very specific set of your "50 such"
combinations.

Why not use a table to hold the valid combinations, rather than try to write
a fairly complex (and likely, "Too complex" from Access' viewpoint)
expression?

Regards

Jeff Boyce
Microsoft Access MVP
I have 20 different tests and each time I have to check a minimum of 2
combinations upto a maximum of 12 different combination to create a
[quoted text clipped - 23 lines]
 
J

Jeff Boyce

I re-checked. The numbers just get bigger and bigger, the more you
"take-at-a-time". You really need to spec' out which ones, so I'm thinking
you are much better off using a table to do that.

Regards

Jeff

Jeff Boyce said:
You might want to revisit the math in your combinatorics.

If you are taking 20 objects (tests) 2 at a time, you have 190 possible
combinations.

Then if you are taking them three at a time, you have approx. 63
possibilities. Taken four at a time, ...

So I'm guessing there are a very specific set of your "50 such"
combinations.

Why not use a table to hold the valid combinations, rather than try to
write a fairly complex (and likely, "Too complex" from Access' viewpoint)
expression?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

mls via AccessMonster.com said:
I have 20 different tests and each time I have to check a minimum of 2
combinations upto a maximum of 12 different combination to create a
results.

simple Ex:
If test1_result=yes and test2_result=no then result="A";
else if test1_result=yes and test2_result=yes then result="Mix A and B";
above example is just checking 2 conditions(tests). I am planning to
check
atleast 12 conditions in one if statement and expecting to have 50 such
if
statements.

Jeff said:
20 objects, taken how many at a time?

"...create a result field ..." ?from what? ?consisting of what?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP

Hi,

[quoted text clipped - 5 lines]

Thanks
 
M

mls via AccessMonster.com

Can you give an example of using a table?

Jeff said:
I re-checked. The numbers just get bigger and bigger, the more you
"take-at-a-time". You really need to spec' out which ones, so I'm thinking
you are much better off using a table to do that.

Regards

Jeff
You might want to revisit the math in your combinatorics.
[quoted text clipped - 45 lines]
 
J

Jeff Boyce

You know your domain better than we do, so the following is only a SWAG ...

If I had 20 potential items, I'd probably put THEM in a table (tall/narrow,
not 20-items-wide). That way I could add/subtract items without having to
do a total remodel of the database.

Then, if I needed some combination of items (say, #7 & #9), I could create a
table that held a single field. In that field I could add a new record
containing "0709" (I'd use zero-fill for the single digit items). Then I
could create a procedure that looks at that [ValidValue] table, divides it
into 2-character groups, and checks the main table (I still don't know where
you have the 'scores' that include the 20) to find records that contain the
first and the second.

The advantage of this approach would be that if you ever decide to use FOUR
of the items, you could add a string like "03171819" to identify a new valid
set (even though this one has four items).

But it will take some coding to pull off.

Don't create a table with 20 yes/no fields and "check" off the valid
combinations -- that's going to cause you some serious pain and remodeling
if the number of items ever changes.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


mls via AccessMonster.com said:
Can you give an example of using a table?

Jeff said:
I re-checked. The numbers just get bigger and bigger, the more you
"take-at-a-time". You really need to spec' out which ones, so I'm
thinking
you are much better off using a table to do that.

Regards

Jeff
You might want to revisit the math in your combinatorics.
[quoted text clipped - 45 lines]
 
T

Tony Toews [MVP]

mls via AccessMonster.com said:
I have 20 different test and have to check for all the permutations and
combinations for each of these test( test1=yes and test2=no and test3=yes etc)
and then finally create a result field.
So what is the best way to do this?

If you tell us what types of tests and results we might be able to
draw on our real world experience and give you some better suggestions
or answers.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 
M

mls via AccessMonster.com

Here is my table with test data.

id a_result b_result c_result d_result
1 0 1 1 1
2 1 0 0 0
3 1 1 1 1
4 0 0 0 0
5 1 1 0 0
;
run;
Using above fields I need to create a final_result field. Say for example

if a_result=1 and b_result=1 and c_result=1 and d_result=1 then
final_result='Measles'
elseif a_result=1 and b_result=1 and c_result=0 and d_result=0 then
final_result='Mumps'

this way I have to generate 50 different if then statements checking at the
maxmimum of 14 different possible conditions.

One though I got is create a lookup take with all the possible combinations
and generate my final_result field. Haven't tried yet.
 
T

Tony Toews [MVP]

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top