4 Replies Latest reply on Jun 20, 2013 2:39 PM by kuhoodva

    Calculation not responding as expected

    kuhoodva

      Title

      Calculation not responding as expected

      Post

           I am using FMP Advanced 12.0v4.

           I have a calculation that I am trying to use as an if statement in a script but I a having difficulty getting a 'true' out of it. Here is the statement:

           FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" ) = "9:00 AM"

           'Global::WorkTimesSummerM'  is a Text field with potential multiple times selected from a check box set

           I have verified through the data viewer that,  FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" ) does equal "9:00 AM", but when I evaluate the entire statement as entered above I get a false (0) as a response. The only way that I have been able to get a true (1) response  is to replace = with ≠. 

           What am I missing here?

           Thanks

        • 1. Re: Calculation not responding as expected
          AppGuy

               It does not return a true or false..

               For instance..

               Filter(”abc123xyz”, “abcdefghijklmnopqrstuvwxyz”) would return abcxyz
               Filter(”abc123xyz”, “123456789”) would return 123

                

               If your looking for a true / false.. you can wrap it in a case statement..

               case(FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" )) = "9:00 AM" ;

          • 2. Re: Calculation not responding as expected
            kuhoodva

                 Thanks for your reply, I must still be missing something here. I thought that FilterValues works a little differently that Filter, but anyway,

                 Trying that it still gives me a false as

            case(FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" )) = "9:00 AM" ; 1; 0 )

            replies with 0

            case(FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" )) = "9:00 AM" ; 1; 2 )

            replies with 2

            case(FilterValues ( Global::WorkTimesSummerM ; "7:00 AM" )) = "9:00 AM" ; 1; 0 )

            replies with 0 

            case(FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" ))  "9:00 AM" ; 1; 0 )

            replies with 1

                  

            Thanks

            • 3. Re: Calculation not responding as expected
              philmodjunk

                   FilterValues, like all the "values" functions, appends a return character to the end of the text. Thus,

              FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" )

              will return:

              "9:00 AM"

                   I suggest this expression to evaluate as True if "9:00 AM" is in the list of values in the field:

                   Not isEmpty ( FilterValues ( Global::WorkTimesSummerM ; "9:00 AM" ) )

              • 4. Re: Calculation not responding as expected
                kuhoodva

                     That is what I was missing. 

                     I like the Not IsEmpty better as well.

                     Thanks Phil