2 Replies Latest reply on Dec 20, 2014 4:31 AM by danlee

    Cannot get Case(Not IsEmpty) script to work

    danlee

      Title

      Cannot get Case(Not IsEmpty) script to work

      Post

      Right now if the number falls within these ranges, "Very High", "High", etc will appear in c_BodyFat_Word field.  But if there is nothing in c_RecentBodyFat field then I want c_BodyFat_Word field to be blank.  Right now the Not IsEmpty script works but if there is data in c_RecentBodyFat field then the data in c_BodyFat_Word field shows up with a "0" instead of, "Very High", "High", etc.  

      Case (not IsEmpty ( c_RecentBodyFat) ; 
      Gender = "Male" and c_RecentBodyFat > .21 ; "Very High" ;
                 Gender = "Female" and c_RecentBodyFat > .34 ; "Very High" ;
      Gender = "Male" and c_RecentBodyFat > .18 and c_RecentBodyFat < .211 ; "High" ;
                 Gender = "Female" and c_RecentBodyFat > .29 and c_RecentBodyFat < .341 ; "High";
      Gender = "Male" and c_RecentBodyFat > .1 and c_RecentBodyFat < .151 ; "Optimal" ;
                 Gender = "Female" and c_RecentBodyFat > .19 and c_RecentBodyFat < .241 ; "Optimal" ;
      Gender = "Male" and c_RecentBodyFat > .15 and c_RecentBodyFat < .181 ; "Moderate" ;
                 Gender = "Female" and c_RecentBodyFat > .24 and c_RecentBodyFat < .291 ; "Moderate" ;
      Gender = "Male" and c_RecentBodyFat > .1 and c_RecentBodyFat < .151 ; "Optimal" ;
                 Gender = "Female" and c_RecentBodyFat> .19 and c_RecentBodyFat < .241 ; "Optimal" ;
      Gender = "Male" and c_RecentBodyFat < .101 ; "Low" ;
                 Gender = "Female" and c_RecentBodyFat < .191 ; "Low" ; "")

        • 1. Re: Cannot get Case(Not IsEmpty) script to work
          Sorbsbuster

          A couple of suggestions, perhaps:

          - You could add an opening bracket here Case (not IsEmpty ( c_RecentBodyFat) ; (
          and a closing bracket here: RecentBodyFat < .191 ; "Low" ) ; "")
          (What you are trying to do is say if c_RecentBodyFat is not empty, then do all of these things, otherwise leave it empty.  What you have got is "If c_RecentBodyFat  is empty, then give the result of Gender = "Male" and c_RecentBodyFat > .21"

          - I would just test for empty as the first test, ie:
          c_RecentBodyFat = "" ; ""

          - Then you can simply list the other tests, say all male first and the female afterwards.  But if you list them in descending order then you don't need to 'pair' them.  Something like (I may have got your figures wrong, and there is a shorter way, but I prefer the clarity of this presentation):

          Case
          (
           c_RecentBodyFat = "" ; "" ; 
          Gender = "Male" and c_RecentBodyFat > .21 ; "Very High" ;
          Gender = "Male" and c_RecentBodyFat > .18 ; "High" ;
          Gender = "Male" and c_RecentBodyFat > .15 ; "Moderate" ;
          Gender = "Male" and c_RecentBodyFat > .1 ; "Optimal" ;
          Gender = "Male" ; "Low" ;
          Gender = "Female"  and c_RecentBodyFat > .34 ; "Very High" ;
          Gender = "Female"  and c_RecentBodyFat > .29 ; "High";
          Gender = "Female"  and c_RecentBodyFat > .24  ; "Moderate" ;
          Gender = "Female"   and c_RecentBodyFat > .19 ; "Optimal" ;
          Gender = "Female"  ; "Low" ;
          "Unknown"
          )

          • 2. Re: Cannot get Case(Not IsEmpty) script to work
            danlee

            That worked! Thank you!