This is a public Forum  publicRSS

Forum post

    Stephen Taylor
    Case vs If statements
    Forum post posted June 17, 2013 by Stephen Taylor 
    78 Views, 3 Comments
    Case vs If statements

    Some time back I asked how to calculate a value (eg. Energy) that has different equations depending on disease (~150 diseases). Case statements would, as suggested, be a simple solution. 3 Q's:

    1. The equations are not just different, but they have 0-6 variables that presumably require a field for entry.

    2. Those 0-6 variables are often different depending on disease.

    3. I'd like to present the user with the variable edit boxes contextually, ie. with some kind of label and only appearing when needed (keep in mind that there are 150).



    • PhilModJunk

      Use a set of related records for your variable, one record for each variable. One field in that set of records can record the value of the variable, a second field can hold the name of that variable. Asking the user for the data needed then becomes a case of presenting them with a portal already loaded with the needed number of related records in a portal with the name fields already populated.

    • Stephen Taylor

      So I could have a related table with eg. Parameter_1 and Parameter_2 fields and, say, 12 records (variables) for Parameter_1 and 4 records (variables) for Parameter_2 equations? And I'd have an Parameter_1_variable name and Parameter_2_variable name fields, ie. a pair of fields for each type of calculation?

    • PhilModJunk

      But I'd use just two fields: Parameter and ParameterName for recording the data, plus a foreign key field for linking to other tables where you'd use the data to compute a result.