12 Replies Latest reply on Aug 11, 2014 3:01 PM by RiannaStar

    Calculate inches to feet

    notJames

      Title

      Calculate inches to feet

      Post

           I would like to create a Height field where if you enter a number, it will automatically format it to feet and inches, including the  feet (') and inch (") marks. Most parents give their kids' height in inches, so i want to be able to reformat it automatically.

           Disclaimer: I can do the math on the fly, but I won't always be the one entering data. Just wanted that out there so I don't appear deficient in simple math  ;)

           I know it more or less involves dividing the number by 12, but it's the formatting that is proving to be a headache.

           Alternatively, if I have both a feet field and inches field, can I make it so that if you enter a number into just the inches field, it does the calc and repopulates both fields (without feet- and inch-mark formatting)?

        • 1. Re: Calculate inches to feet
          philmodjunk

               Feet will be:

               Div ( HeightInInches ; 12 )

               Remaining inches will be:

               Mod ( HeightInInches ; 12 )

          • 2. Re: Calculate inches to feet
            RiannaStar

                 This forum helped but I cannot get it to display as in and feet.

                 i.e. I was able to format the field "lowered height" = 135 

                 to "lowered height ft" = 113. 

                 I need it to say 11' 3" 

                 Can anyone help?

                  

            • 3. Re: Calculate inches to feet
              philmodjunk

                   Let ( [ ft = Div ( HeightInInches ; 12 ) ;
                              in = Mod ( HeightInInches ; 12 ) ] ;
                              If ( ft ; ft & "'" ) & in & "\""
                           )

              • 4. Re: Calculate inches to feet
                philmodjunk

                     "'" is a single quote enclosed in double quotes.

                • 5. Re: Calculate inches to feet
                  notJames

                       So I used that last calc to format a height field with the height and inch marks.

                       Now I want that field to be the result of one of two different entries. I have a popover that allows the user to enter either total inches (Field 1) or feet and inches (Fields 2 and 3). What calculation should I use for that?

                       Or alternatively, how do I override the calculated height field so that the user can just enter the feet and inches manually?

                  • 6. Re: Calculate inches to feet
                    philmodjunk

                         There's more than one way to do that. Here's one:

                         If ( IsEmpty ( HeightInInches ) ;
                              FeetFIeld & "' " & InchesField & "\"" ;
                              Let ( [ ft = Div ( HeightInInches ; 12 ) ;
                                         in = Mod ( HeightInInches ; 12 ) ] ;
                                         If ( ft ; ft & "'" ) & in & "\""
                                     )// Let
                              ) // IF

                    • 7. Re: Calculate inches to feet
                      philmodjunk

                           There's more than one way to do that. Here's one:

                           If ( IsEmpty ( HeightInInches ) ;
                                FeetFIeld & "' " & InchesField & "\"" ;
                                Let ( [ ft = Div ( HeightInInches ; 12 ) ;
                                           in = Mod ( HeightInInches ; 12 ) ] ;
                                           If ( ft ; ft & "'" ) & in & "\""
                                       )// Let
                                ) // IF

                      • 8. Re: Calculate inches to feet
                        RiannaStar

                             Hello,

                             Thank you for the replies.

                             Let me be more specific because I for some reason can't figure it out. 

                             The first field "lowered height" I manually enter in inches.

                             The next field is "Lowered height Feet" I need it to auto populate from the "Lowered height" field but display in ft & in.

                             i.e. if I type in 109" "Lowered Height Feet" to display automatically as 9ft 1in.

                             I currently have it formatted as "Div ( Lowered Height ; 12) &  Mod ( Lowered Height ; 12 )"

                             and the Lowered Height Feet is displaying as "91" instead of 9ft 1in. ....

                              

                             Can anyone help?

                              

                             Kind Regards,

                             Rianna Star

                        • 9. Re: Calculate inches to feet
                          philmodjunk

                               That's why I set up the calculation like this:

                                 Let ( [ ft = Div ( HeightInInches ; 12 ) ;
                                               in = Mod ( HeightInInches ; 12 ) ] ;
                                               If ( ft ; ft & "'" ) & in & "\""
                                           )//Let

                               If ( ft ; ft & "'" ) & in & "\""

                               Is the part that takes the values computed by the Div and Mod functions and inserts the needed foot and inches symbols. in the expression, ft & "'", you have a single quote (for the feet symbol) enclosed in double quotes.

                          • 10. Re: Calculate inches to feet
                            RiannaStar

                                 I'm sorry I guess I don't understand.... the only way I could get it to work was with the inserted "lowered height" in the formula but I guess I'm not Pro savvy enough to translate yours to mine....

                                 Thanks though

                                  

                            • 11. Re: Calculate inches to feet
                              philmodjunk

                                     Let ( [ ft = Div ( Lowered height Feet; 12 ) ;
                                                   in = Mod ( Lowered height Feet; 12 ) ] ;
                                                   If ( ft ; ft & "'" ) & in & "\""
                                               )//Let

                              • 12. Re: Calculate inches to feet
                                RiannaStar

                                     Ok I got it! I thought for sure I had already tried it like that, but must have done something wrong. It works now! Thank You!