6 Replies Latest reply on May 11, 2011 2:38 PM by LaRetta_1

    Case statement left numbers and a range

    kilbot

      Title

      Case statement left numbers and a range

      Post

      Here's what I have not sure where I am going wrong?

      Left (number_contract ; 2) =  ≥ 13  and  ≤ 99; "Head Quarters";

        • 1. Re: Case statement left numbers and a range
          philmodjunk

          Try:

          GetAsNumber (Left (number_contract ; 2) ) ≥ 13  and  GetAsNumber (Left (number_contract ; 2) ) ≤ 99 ; ...

          Which can be rewritten as:

          Let ( Digits = GetAsNumber (Left (number_contract ; 2) ) ; Case ( Digits ≥ 13  and Digits  ≤ 99 ) ; ...

          • 2. Re: Case statement left numbers and a range
            kilbot

            Question will that get rid of the issue that the case statement that I wrote keeps dropping the leading zero when saved?

            Here is what I wrote but when I wrote it everything was = 01, = 02, ..... = 12

            Case (Left ( number_contract ; 2) = 1; "District 1";
            Left (number_contract ; 2) = 2; "District 02";
            Left ( number_contract ; 2) = 3; "District 03";
            Left ( number_contract ; 2) = 4; "District 04";
            Left ( number_contract ; 2) = 5; "District 05";
            Left ( number_contract ; 2) = 6; "District 06";
            Left (number_contract ; 2) = 7; "District 07";
            Left ( number_contract ; 2) = 8; "District 08";
            Left ( number_contract ; 2) = 9; "District 09";
            Left (number_contract ; 2) = 10; "District 10";
            Left ( number_contract ; 2) = 11; "District 11";
            Left ( number_contract ; 2) = 12; "District 12";
            Left (number_contract ; 2) =  13; "Head Quarters";
            )

            • 3. Re: Case statement left numbers and a range
              philmodjunk

              If you are comparing a value to a number, you need to make sure the type produced by your expression is of type number.

              When they are of type number, 01 = 1 is a true statement. When they are of type text, "01" = "1" is False.

              • 4. Re: Case statement left numbers and a range
                LaRetta_1

                Isn’t the field number_contract a number field which only holds the number 1, 2, 3 etc and you want to assign the text equivalent of district (with leading zero or as headquarters) in a new calculation?  Is this correct?  And you want to pad the number with leading zero if less than 2 places?

                Try calculation, result is text with:

                Case (
                number_contract  ≥ 13 and number_contract ≤  99 ; "Head Quarters" ;
                "District " & Right ( "00" & number_contract ; 2 )
                )

                BTW, Head Quarters is normally spelled Headquarters.

                • 5. Re: Case statement left numbers and a range
                  philmodjunk

                  Unless it's a Head divided in to 4ths Surprised