4 Replies Latest reply on Oct 21, 2013 9:41 AM by Annette

    Case Statement Help

    Annette

      Title

      Case Statement Help

      Post

           I have the following Case statement:

            

           Case ( ImmediateStart = "Yes"; "P1 - Immediate Start"; Category = "5a" and ImmediateStart = "No" ; "P2 - 5a "; Category = "5i" and ImmediateStart = "No" ; "P3 - 5i "; Category = "5" and ImmediateStart = "No" ; "P4 - Remaining Category 5 "; Category = "4" and ImmediateStart = "No" ; "P5 - Category 4's")

           For the two sections I have in bold what I'm trying to say is:

           If there are any other category 5's other than those listed previous in the statement, make them P4..etc 

           And for any category 4's (regardless of the letter after the 4) and immediate start = No make them P5 Category 4's.  

           I just don't know how to basically say the remaining different category 5's and all the category 4's as they would all have a letter after them.

            

           Thanks!

        • 1. Re: Case Statement Help
          philmodjunk

               The return key and space bar can help make case functions easier to read an analyze. The following format will work directly in your specify calculation dialog. But what you are trying to do with your quoted result expressions is not at all clear to me.

               Case ( ImmediateStart = "Yes"; "P1 - Immediate Start";
                           Category = "5a" ; "P2 - 5a ";
                           Category = "5i" ; "P3 - 5i ";
                      GetAsNumber ( Category ) = 5 ; "P4 - Remaining Category 5 ";
                           GetAsNumber ( Category ) = 4  ; "P5 - Category 4's"
                         ) // case

               You can omit the and ImmediateStart = "No" terms since if immediateStart is "yes", the very first result text: "P1 - Immediate Start" will be returned and none of the following comparison expresions (boolean expressions) will be evaluated. GetAsNumber will strip off all the following non-numeric characters and evaluate the field as a number to compare to 4 or 5 in the last two Boolean expressions.

               Left ( Category ; 1 ) = 5 might also work if only single digit numbers are possible for your values in Category.

          • 2. Re: Case Statement Help
            Annette

                 Basically there can be any of the following Categories:  5a, 5h, 5i, 5s, 4a, 4b, 4h, 4m, 4s.  

                 There also can be any of those above categories that are identified as an immediate start.  So a 5a can be an immediate start.  

                 The immediate start field would be a priority over the 5a category which is why I thought I had to say if immediatestart=no in all the other ones.  Joy if I don't have to add that extra text.  

                 But as you can see although there are multiple categories for both 4's and 5's, they only want to single out the category 5a, 5i and the other 5's can be grouped and all 4's can be grouped.

            • 3. Re: Case Statement Help
              philmodjunk

                   So does this calculation work for you?

              • 4. Re: Case Statement Help
                Annette

                     I just tried it and it seems to work fine thanks very much for that!