Validate result

  • Hi,

    I am trying to process results to this question:

    "What optional subjects do you study?"

    Results could be one or many of these options:

    1 Option1

    2 Option2

    8 None

    9 NotKnown

    I would like to check if results for each student are valid or not by checking these rules:

    If duplicate codes then invalid result

    if 8 & another code then invalid result

    if 9 & another code then invalid result

     

    [Options table]
    1 Option1
    2 Option2
    8 None
    9 NotKnown

    [Answers table]
    Student Answer
    100 1
    100 2

    101 1
    101 9

    Student 100 answers are valid.
    Student 101 answers are not valid because they break rule number3

    Which is the best way to implement these 3 rules ?

    TIA

    • This topic was modified 2 years ago by  Johnson330.
  • Are your results already in a table?

    Sounds like these are all separate questions... Could you post a script that creates and populates a table with your sample data?

  • Johnson330 wrote:

    Hi, I am trying to process results to this question: "What optional subjects do you study?"

    Results could be one or many of these options: 1 Option1 2 Option2 8 None 9 NotKnown

    I would like to check if results for each student are valid or not by checking these rules:

    If duplicate codes then invalid result if 8 & another code then invalid result if 9 & another code then invalid result

    Which is the best way to implement these 3 rules ? TIA

    Please identify he table structure of the "answers" table.  Also, please identify what "duplicate code"s consists of if not a part of the 3 rules you posted.

    In the meantime, use CASE from the bottom up because CASE is evaluated from the top down.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • [Options table]

    1 Option1

    2 Option2

    8 None

    9 NotKnown

    [Answers table]

    Student Answer

    100 1

    100 2

    101 1

    101 9

    Student 100 answers are valid.

    Student 101 answers are not valid because they break rule number3

  • Johnson330 wrote:

    [Options table] 1 Option1 2 Option2 8 None 9 NotKnown

    [Answers table] Student Answer 100 1 100 2

    101 1 101 9

    Student 100 answers are valid. Student 101 answers are not valid because they break rule number3

    There don't appear to be any question numbers in either of those tables.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • You also list the 3 conditions, as follows...

    If duplicate codes then invalid result

    if 8 & another code then invalid result

    if 9 & another code then invalid result

    For the first rule, are you suggesting that a student could answer, for example, with an "8" more than once for the same question?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply