6 Replies Latest reply on Feb 4, 2013 11:41 AM by VanessaAnne

    Calculation Field Format - How to Override

    VanessaAnne

      Title

      Calculation Field Format - How to Override

      Post

           Hello, 

           I have a calculation field that adds two height measurements.  The calculation however shows a result as a number even when the field is defined to result in text.  I need the result to be in inches/feet since it's a height measurement. 

           The source fields which is providing the calculated criteria are both entered in inches/feet but yet the result is always a number.  So if 5'6" is entered, the calculation result is coming to 56. 

           Is there a way to override this? Since it is a calculation field it is not modifiable. 

           Thanks! 

        • 1. Re: Calculation Field Format - How to Override
          philmodjunk

               The field should not be modifiable. I don't see a reason why you need it to be either.

               It would appear you need a calculation that takes text from fields of type text, extracts the feet and inches as separate values, add them--adjusting the results to be displayed in feet and inches with the inches always less than 12.

               Let's say field A is a text field with your first measuremnt in 5' 6" format. Field A is a text field with the same type of measurement in identical format.

               Your calculation could be:

               Let ( [ Af = GetAsNumber ( Leftwords ( FieldA ; 1 ) ) ;
                         Ai = GetAsNumber ( Rightwords ( FieldA ; 1 ) ) ;
                         Bf = GetAsNumber ( Leftwords ( FieldB ; 1 ) ) ;
                         Bi = GetAsNumber ( Rightwords ( FieldB ; 1 ) ) ;
                         Iab = Ai + Bi
                        ];
                       Af + Bf + Div ( Iab ; 12 ) & "' " & Mod ( Iab ; 12 ) & "\""
                      )

          • 2. Re: Calculation Field Format - How to Override
            VanessaAnne

                 Thank you.  This is what I've entered.  Field A = Camera Height from Floor.  Field B = Floor Height from Camera

                  

                 I am getting an error message - please see attached. referring to the first "[" 

                  

                  

                 ( [ Camera Height From Floor = GetAsNumber ( Leftwords ( Camera Height From Floor ; 1 ) ) ;
                           Camera Height From Floor = GetAsNumber ( Rightwords ( Camera Height From Floor ; 1 ) ) ;
                           Camera Height From Ground = GetAsNumber ( Leftwords ( Floor Height From Ground ; 1 ) ) ;
                           Camera Height From Ground = GetAsNumber ( Rightwords ( Floor Height From Ground ; 1 ) ) ;
                           Iab = Camera Height From Floor + Camera Height From Ground
                          ];
                         Camera Height From Floor + Camera Height From Ground + Div ( Iab ; 12 ) & "' " & Mod ( Iab ; 12 ) & "\""
                        )
            • 3. Re: Calculation Field Format - How to Override
              philmodjunk

                   You appear to be missing the name of the enclosing funciton: Let.

                   And you will not get the correct results even with this correction. You need to have 5 distinct variables where you currently have these three:

                   Camera Height From Floor, Camera Height From Ground, Iab

                   To explain how I named the variables in my suggested example:

                   Af stands for "feet from Field A"

                   Ai stands for "inches from Field A"

              • 4. Re: Calculation Field Format - How to Override
                VanessaAnne

                     Gotcha.  The calculation is resulting now but it doesn't seem correct. 

                     These are the values I'm working with: 

                Field A = Camera Height from Floor.  5'6"

                Field B = Floor Height from Camera.  0'0"  

                     Calculated result = 66'2"  (when it should be 5'6" since the floor height and camera height are the same in this instance) 

                • 5. Re: Calculation Field Format - How to Override
                  philmodjunk

                       Please read my last post again:

                       You apparently have this calculation:

                       Let ( [ Camera Height From Floor = GetAsNumber ( Leftwords ( Camera Height From Floor ; 1 ) ) ;

                                 Camera Height From Floor = GetAsNumber ( Rightwords ( Camera Height From Floor ; 1 ) ) ;
                                 Camera Height From Ground = GetAsNumber ( Leftwords ( Floor Height From Ground ; 1 ) ) ;
                                 Camera Height From Ground = GetAsNumber ( Rightwords ( Floor Height From Ground ; 1 ) ) ;
                                 Iab = Camera Height From Floor + Camera Height From Ground
                                ];
                               Camera Height From Floor + Camera Height From Ground + Div ( Iab ; 12 ) & "' " & Mod ( Iab ; 12 ) & "\""
                              )
                       You are using the same variable name for both inches and feet from the same field. Where you use the same name twice in red, you need two different names. The same is true for where you use the same name twice in blue.
                        
                       One possible way that you could correct this:

                            Let ( [ Camera Height From FloorFeet = GetAsNumber ( Leftwords ( Camera Height From Floor ; 1 ) ) ;

                                      Camera Height From FloorInches = GetAsNumber ( Rightwords ( Camera Height From Floor ; 1 ) ) ;
                                      Camera Height From GroundFeet = GetAsNumber ( Leftwords ( Floor Height From Ground ; 1 ) ) ;
                                      Camera Height From GroundInches = GetAsNumber ( Rightwords ( Floor Height From Ground ; 1 ) ) ;
                                      Iab = Camera Height From Floor Inches + Camera Height From Ground Inches
                                     ];
                                    Camera Height From Floor Feet + Camera Height From Ground Feet  + Div ( Iab ; 12 ) & "' " & Mod ( Iab ; 12 ) & "\""
                                   )
                        
                  • 6. Re: Calculation Field Format - How to Override
                    VanessaAnne

                         Yes, thank you that worked.  I had something switched around.  Very much appreciate it.